/** * @param $structureAsPHPString * @param array $dataToEvaluate * @return mixed * @throws NotSupportedException */ public static function resolveBooleansDataToPHPString($structureAsPHPString, array $dataToEvaluate) { assert('is_string($structureAsPHPString)'); $evaluatedString = $structureAsPHPString; foreach ($dataToEvaluate as $key => $boolean) { if (!is_bool($boolean)) { throw new NotSupportedException(); } $evaluatedString = str_replace($key, BooleanUtil::boolToString($boolean), strtolower($evaluatedString)); } return $evaluatedString; }
/** * Run this widget. * This method registers necessary javascript and renders the needed HTML code. */ public function run() { Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->id, "designer.init(\n " . BooleanUtil::boolToString($this->canAddPanels) . ",\n " . BooleanUtil::boolToString($this->canModifyPanelSettings) . ",\n " . BooleanUtil::boolToString($this->canRemovePanels) . ",\n " . BooleanUtil::boolToString($this->canMovePanels) . ",\n " . BooleanUtil::boolToString($this->canAddRows) . ",\n " . BooleanUtil::boolToString($this->canMoveRows) . ",\n " . BooleanUtil::boolToString($this->canRemoveRows) . ",\n " . BooleanUtil::boolToString($this->canModifyCellSettings) . ",\n " . BooleanUtil::boolToString($this->canMergeAndSplitCells) . ",\n " . BooleanUtil::boolToString($this->mergeRowAndAttributePlacement) . ",\n " . $this->maxCellsPerRow . ",\n '" . $this->getPanelSettingsDisplay(null, false, false, '{panelId}') . "',\n '" . $this->getCellSettingsDisplay(false, '{cellId}') . "'\n );"); echo $this->renderLayoutTools(); echo $this->renderLayout(); }
/** * Given an installSettingsForm, run the install including the schema creation and default data load. This is * used by the interactive install and the command line install. * @param object $form * @param object $messageStreamer */ public static function runInstallation($form, &$messageStreamer) { Yii::app()->params['isFreshInstall'] = true; assert('$form instanceof InstallSettingsForm'); assert('$messageStreamer instanceof MessageStreamer'); if (defined('IS_TEST')) { $perInstanceFilename = "perInstanceTest.php"; $debugFilename = "debugTest.php"; } else { @set_time_limit(1200); $perInstanceFilename = "perInstance.php"; $debugFilename = "debug.php"; } $messageStreamer->add(Zurmo::t('InstallModule', 'Connecting to Database.')); static::connectToDatabase($form->databaseType, $form->databaseHostname, $form->databaseName, $form->databaseUsername, $form->databasePassword, $form->databasePort); ForgetAllCacheUtil::forgetAllCaches(); $messageStreamer->add(Zurmo::t('InstallModule', 'Dropping existing tables.')); ZurmoRedBean::$writer->wipeAll(); $messageStreamer->add(Zurmo::t('InstallModule', 'Creating super user.')); $messageLogger = new MessageLogger($messageStreamer); $messageLogger->logDateTimeStamp = false; Yii::app()->custom->runBeforeInstallationAutoBuildDatabase($messageLogger); $messageStreamer->add(Zurmo::t('InstallModule', 'Starting database schema creation.')); $startTime = microtime(true); $messageStreamer->add('debugOn:' . BooleanUtil::boolToString(YII_DEBUG)); $messageStreamer->add('phpLevelCaching:' . BooleanUtil::boolToString(PHP_CACHING_ON)); $messageStreamer->add('memcacheLevelCaching:' . BooleanUtil::boolToString(MEMCACHE_ON)); static::autoBuildDatabase($messageLogger, false); $endTime = microtime(true); $messageStreamer->add(Zurmo::t('InstallModule', 'Total autobuild time: {formattedTime} seconds.', array('{formattedTime}' => number_format($endTime - $startTime, 3)))); if (SHOW_QUERY_DATA) { $messageStreamer->add(FooterView::getTotalAndDuplicateQueryCountContent()); $messageStreamer->add(PageView::makeNonHtmlDuplicateCountAndQueryContent()); } $messageStreamer->add(Zurmo::t('InstallModule', 'Database schema creation complete.')); $messageStreamer->add(Zurmo::t('InstallModule', 'Rebuilding Permissions.')); AllPermissionsOptimizationUtil::rebuild(); $messageStreamer->add(Zurmo::t('InstallModule', 'Rebuilding Read Permissions Subscription tables.')); ReadPermissionsSubscriptionUtil::buildTables(); $messageStreamer->add(Zurmo::t('InstallModule', 'Writing Configuration File.')); static::writeConfiguration(INSTANCE_ROOT, $form->databaseType, $form->databaseHostname, $form->databaseName, $form->databaseUsername, $form->databasePassword, $form->databasePort, $form->memcacheHostname, (int) $form->memcachePortNumber, true, Yii::app()->language, $perInstanceFilename, $debugFilename, $form->hostInfo, $form->scriptUrl, $form->submitCrashToSentry); static::setZurmoTokenAndWriteToPerInstanceFile(INSTANCE_ROOT); ZurmoPasswordSecurityUtil::setPasswordSaltAndWriteToPerInstanceFile(INSTANCE_ROOT); static::createSuperUser('super', $form->superUserPassword); $messageStreamer->add(Zurmo::t('InstallModule', 'Setting up default data.')); DefaultDataUtil::load($messageLogger); static::createBaseControlUserConfigUtilUserAccount(); Yii::app()->custom->runAfterInstallationDefaultDataLoad($messageLogger); // Send notification to super admin to delete test.php file in case if this // installation is used in production mode. $message = new NotificationMessage(); $message->textContent = Zurmo::t('InstallModule', 'If this website is in production mode, please remove the app/test.php file.'); $rules = new RemoveApiTestEntryScriptFileNotificationRules(); NotificationsUtil::submit($message, $rules); // If minify is disabled, inform user that they should fix issues and enable minify $setIncludePathServiceHelper = new SetIncludePathServiceHelper(); if (!$setIncludePathServiceHelper->runCheckAndGetIfSuccessful()) { $message = new NotificationMessage(); $message->textContent = Zurmo::t('InstallModule', 'Minify has been disabled due to a system issue. Try to resolve the problem and re-enable Minify.'); $rules = new EnableMinifyNotificationRules(); NotificationsUtil::submit($message, $rules); } $messageStreamer->add(Zurmo::t('InstallModule', 'Installation Complete.')); Yii::app()->params['isFreshInstall'] = false; }
public function testBoolToString() { $this->assertEquals('true', BooleanUtil::boolToString(true)); $this->assertEquals('false', BooleanUtil::boolToString(false)); }
/** * to change isActive attribute properly during save */ protected function setIsActive() { if (Right::DENY == $this->getExplicitActualRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB) || Right::DENY == $this->getExplicitActualRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_MOBILE) || Right::DENY == $this->getExplicitActualRight('UsersModule', UsersModule::RIGHT_LOGIN_VIA_WEB_API)) { $isActive = false; } else { $isActive = true; } if ($this->isActive != $isActive) { $data = array(strval($this), array('isActive'), BooleanUtil::boolToString((bool) $this->isActive), BooleanUtil::boolToString((bool) $isActive)); AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_MODIFIED, $data, $this); $this->unrestrictedSet('isActive', $isActive); $this->save(); } }