Пример #1
0
 /**
  * @param   mixed   $param
  * @return  string|null
  */
 public static function toString($param)
 {
     if (BooleanUtil::isTrue($param)) {
         return 'true';
     }
     if (BooleanUtil::isFalse($param)) {
         return 'false';
     } else {
         return null;
     }
 }
Пример #2
0
 /**
  * Render A standard text input.
  * @return The element's content as a string.
  */
 protected function renderControlEditable()
 {
     assert('empty($this->model->{$this->attribute}) ||
             is_string($this->model->{$this->attribute}) ||
             is_integer(BooleanUtil::boolIntVal($this->model->{$this->attribute}))');
     $htmlOptions = array();
     $htmlOptions['id'] = $this->getEditableInputId();
     $htmlOptions['name'] = $this->getEditableInputName();
     if ($this->getDisabledValue()) {
         $htmlOptions['disabled'] = $this->getDisabledValue();
         if (BooleanUtil::boolVal($this->model->{$this->attribute})) {
             $htmlOptions['uncheckValue'] = 1;
         }
     }
     return $this->form->checkBox($this->model, $this->attribute, $htmlOptions);
 }
Пример #3
0
 protected function getEditableHtmlOptions()
 {
     $htmlOptions = array();
     $htmlOptions['id'] = $this->getEditableInputId();
     $htmlOptions['name'] = $this->getEditableInputName();
     if ($this->getDisabledValue()) {
         $htmlOptions['disabled'] = $this->getDisabledValue();
         if (BooleanUtil::boolVal($this->model->{$this->attribute})) {
             $htmlOptions['uncheckValue'] = 1;
         }
         if ($htmlOptions['disabled'] == 'disabled') {
             $htmlOptions['labelClass'] = 'disabled';
         }
     }
     return $htmlOptions;
 }
Пример #4
0
 /**
  * Save layout changes including:
  *  collapse/show
  *  position change
  *  removed portlets
  *
  */
 public function actionSaveLayout()
 {
     $portlets = Portlet::getByLayoutIdAndUserSortedById($_POST['portletLayoutConfiguration']['uniqueLayoutId'], Yii::app()->user->userModel->id);
     $portletsStillOnLayout = array();
     if (!empty($_POST['portletLayoutConfiguration']['portlets'])) {
         foreach ($_POST['portletLayoutConfiguration']['portlets'] as $key => $portletPostData) {
             $idParts = explode("_", $portletPostData['id']);
             $portlets[$idParts[1]]->column = $portletPostData['column'] + 1;
             $portlets[$idParts[1]]->position = $portletPostData['position'] + 1;
             $portlets[$idParts[1]]->collapsed = BooleanUtil::boolVal($portletPostData['collapsed']);
             $portlets[$idParts[1]]->save();
             $portletsStillOnLayout[$idParts[1]] = $idParts[1];
         }
     }
     foreach ($portlets as $portletId => $portlet) {
         if (!isset($portletsStillOnLayout[$portletId])) {
             $portlet->delete();
         }
     }
 }
 /**
  * Given a chart data provider and some chart parameters, creates a fusion chart object and returns it.
  */
 public static function makeChartByChartDataProvider($dataProvider, $chartParams)
 {
     assert('$dataProvider instanceof ChartDataProvider');
     assert('is_array($chartParams)');
     Yii::import('ext.fusioncharts.FusionChartMaker');
     $fusionChart = new FusionChartMaker();
     $fusionChart->setChartParam('rotateNames', 0);
     $fusionChart->setChartParam('xAxisName', $dataProvider->getXAxisName());
     $fusionChart->setChartParam('showValues', BooleanUtil::boolIntVal($chartParams['showValues']));
     $fusionChart->setChartParam('yAxisName', $dataProvider->getYAxisName());
     $currencySymbol = Yii::app()->locale->getCurrencySymbol(Yii::app()->currencyHelper->getCodeForCurrentUserForDisplay());
     $fusionChart->setChartParam('numberPrefix', $currencySymbol);
     $fusionChart->setChartParam('decimalPrecision', 0);
     //Where should this be coming from? todo:
     $fusionChart->setChartParam('formatNumberScale', 1);
     $chartData = $dataProvider->getChartData();
     foreach ($chartData as $seriesData) {
         $fusionChart->addChartData($seriesData['value'], "name=" . $seriesData['displayLabel']);
         // Not Coding Standard
     }
     return $fusionChart;
 }
 /**
  * @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();
 }
Пример #8
0
 public function testBoolIntToString()
 {
     $this->assertEquals('true', BooleanUtil::boolIntToString(1));
     $this->assertEquals('false', BooleanUtil::boolIntToString(0));
 }
Пример #9
0
 /**
  * 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;
 }
Пример #10
0
 /**
  * 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();
     }
 }