public function testMakeFormAndSetConfigurationFromForm() { $billy = User::getByUsername('billy'); Yii::app()->timeZoneHelper->setTimeZone('America/New_York'); Yii::app()->pagination->setGlobalValueByType('listPageSize', 50); Yii::app()->pagination->setGlobalValueByType('subListPageSize', 51); Yii::app()->pagination->setGlobalValueByType('modalListPageSize', 52); Yii::app()->pagination->setGlobalValueByType('dashboardListPageSize', 53); ZurmoConfigurationUtil::setByModuleName('ZurmoModule', 'applicationName', 'demoCompany'); $form = ZurmoConfigurationFormAdapter::makeFormFromGlobalConfiguration(); $this->assertEquals('America/New_York', $form->timeZone); $this->assertEquals(50, $form->listPageSize); $this->assertEquals(51, $form->subListPageSize); $this->assertEquals(52, $form->modalListPageSize); $this->assertEquals(53, $form->dashboardListPageSize); $this->assertEquals('demoCompany', $form->applicationName); $form->timeZone = 'America/Chicago'; $form->listPageSize = 60; $form->subListPageSize = 61; $form->modalListPageSize = 62; $form->dashboardListPageSize = 63; $form->applicationName = 'demoCompany2'; ZurmoConfigurationFormAdapter::setConfigurationFromForm($form); $form = ZurmoConfigurationFormAdapter::makeFormFromGlobalConfiguration(); $this->assertEquals('America/Chicago', $form->timeZone); $this->assertEquals(60, $form->listPageSize); $this->assertEquals(61, $form->subListPageSize); $this->assertEquals(62, $form->modalListPageSize); $this->assertEquals(63, $form->dashboardListPageSize); $this->assertEquals('demoCompany2', $form->applicationName); }
protected function renderContent() { $homeUrl = Yii::app()->createUrl('home/default'); $content = '<div class="clearfix">'; $content .= '<a href="#" id="nav-trigger" title="Toggle Navigation">›</a>'; $content .= '<div id="corp-logo">'; if ($logoFileModelId = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'logoFileModelId')) { $logoFileModel = FileModel::getById($logoFileModelId); $logoFileSrc = Yii::app()->getAssetManager()->getPublishedUrl(Yii::getPathOfAlias('application.runtime.uploads') . DIRECTORY_SEPARATOR . $logoFileModel->name); } else { $logoFileSrc = Yii::app()->themeManager->baseUrl . '/default/images/Zurmo_logo.png'; } $logoHeight = ZurmoConfigurationFormAdapter::resolveLogoHeight(); $logoWidth = ZurmoConfigurationFormAdapter::resolveLogoWidth(); if (Yii::app()->userInterface->isMobile()) { $content .= '<a href="' . $homeUrl . '"><img src="' . $logoFileSrc . '" alt="Zurmo Logo" /></a>'; //make sure width and height are NEVER defined } else { $content .= '<a href="' . $homeUrl . '"><img src="' . $logoFileSrc . '" alt="Zurmo Logo" height="' . $logoHeight . '" width="' . $logoWidth . '" /></a>'; } if ($this->applicationName != null) { $content .= ZurmoHtml::tag('span', array(), $this->applicationName); } $content .= '</div>'; if (!empty($this->userMenuItems) && !empty($this->settingsMenuItems)) { $content .= '<div id="user-toolbar" class="clearfix">'; $content .= static::renderHeaderMenus($this->userMenuItems, $this->settingsMenuItems); $content .= '</div>'; } $content .= '</div>'; return $content; }
protected function renderContent() { //ZurmoNotificationUtil::renderDesktopNotificationsScript(); Disabled for now until better browser support if (ZurmoConfigurationFormAdapter::getRealtimeUpdatesEnabled()) { ZurmoNotificationUtil::renderAutoUpdaterScript(); } return $this->verticalGridView->render(); }
public function testMakeFormAndSetConfigurationFromForm() { $billy = User::getByUsername('billy'); Yii::app()->timeZoneHelper->setTimeZone('America/New_York'); Yii::app()->pagination->setGlobalValueByType('listPageSize', 50); Yii::app()->pagination->setGlobalValueByType('subListPageSize', 51); Yii::app()->pagination->setGlobalValueByType('modalListPageSize', 52); Yii::app()->pagination->setGlobalValueByType('dashboardListPageSize', 53); ZurmoConfigurationUtil::setByModuleName('ZurmoModule', 'applicationName', 'demoCompany'); $logoFileName = 'testLogo.png'; $logoFilePath = Yii::getPathOfAlias('application.modules.zurmo.tests.unit.files') . DIRECTORY_SEPARATOR . $logoFileName; ZurmoConfigurationFormAdapter::resizeLogoImageFile($logoFilePath, $logoFilePath, null, ZurmoConfigurationForm::DEFAULT_LOGO_HEIGHT); $logoFileId = ZurmoConfigurationFormAdapter::saveLogoFile($logoFileName, $logoFilePath, 'logoFileModelId'); ZurmoConfigurationFormAdapter::publishLogo($logoFileName, $logoFilePath); ZurmoConfigurationUtil::setByModuleName('ZurmoModule', 'logoFileModelId', $logoFileId); ZurmoConfigurationUtil::setByModuleName('ZurmoModule', 'logoThumbFileModelId', $logoFileId); $form = ZurmoConfigurationFormAdapter::makeFormFromGlobalConfiguration(); $this->assertEquals('America/New_York', $form->timeZone); $this->assertEquals(50, $form->listPageSize); $this->assertEquals(51, $form->subListPageSize); $this->assertEquals(52, $form->modalListPageSize); $this->assertEquals(53, $form->dashboardListPageSize); $this->assertEquals('demoCompany', $form->applicationName); $this->assertEquals(AutoresponderOrCampaignBatchSizeConfigUtil::CONFIG_DEFAULT_VALUE, $form->autoresponderOrCampaignBatchSize); $this->assertEquals(UnsubscribeAndManageSubscriptionsPlaceholderUtil::getContentByType(false), $form->autoresponderOrCampaignFooterPlainText); $this->assertEquals(UnsubscribeAndManageSubscriptionsPlaceholderUtil::getContentByType(true), $form->autoresponderOrCampaignFooterRichText); $this->assertEquals($logoFileName, $form->logoFileData['name']); $form->timeZone = 'America/Chicago'; $form->listPageSize = 60; $form->subListPageSize = 61; $form->modalListPageSize = 62; $form->dashboardListPageSize = 63; $form->applicationName = 'demoCompany2'; $form->autoresponderOrCampaignBatchSize = 20; $logoFileName2 = 'testLogo2.png'; $form->autoresponderOrCampaignFooterPlainText = 'abc'; $form->autoresponderOrCampaignFooterRichText = 'def'; $logoFilePath2 = Yii::getPathOfAlias('application.modules.zurmo.tests.unit.files') . DIRECTORY_SEPARATOR . $logoFileName2; copy($logoFilePath2, sys_get_temp_dir() . DIRECTORY_SEPARATOR . $logoFileName2); copy($logoFilePath2, sys_get_temp_dir() . DIRECTORY_SEPARATOR . ZurmoConfigurationForm::LOGO_THUMB_FILE_NAME_PREFIX . $logoFileName2); Yii::app()->user->setState('logoFileName', $logoFileName2); ZurmoConfigurationFormAdapter::setConfigurationFromForm($form); $form = ZurmoConfigurationFormAdapter::makeFormFromGlobalConfiguration(); $this->assertEquals('America/Chicago', $form->timeZone); $this->assertEquals(60, $form->listPageSize); $this->assertEquals(61, $form->subListPageSize); $this->assertEquals(62, $form->modalListPageSize); $this->assertEquals(63, $form->dashboardListPageSize); $this->assertEquals('demoCompany2', $form->applicationName); $this->assertEquals(20, $form->autoresponderOrCampaignBatchSize); $this->assertEquals('abc', $form->autoresponderOrCampaignFooterPlainText); $this->assertEquals('def', $form->autoresponderOrCampaignFooterRichText); $this->assertEquals($logoFileName2, $form->logoFileData['name']); }
public function handlePublishLogoAssets($event) { if (null !== ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'logoFileModelId')) { $logoFileModelId = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'logoFileModelId'); $logoFileModel = FileModel::getById($logoFileModelId); $logoFileSrc = Yii::app()->getAssetManager()->getPublishedUrl(Yii::getPathOfAlias('application.runtime.uploads') . DIRECTORY_SEPARATOR . $logoFileModel->name); //logoFile is either not published or we have dangling url for asset if ($logoFileSrc === false || file_exists($logoFileSrc) === false) { //Logo file is not published in assets //Check if it exists in runtime/uploads if (file_exists(Yii::getPathOfAlias('application.runtime.uploads') . DIRECTORY_SEPARATOR . $logoFileModel->name) === false) { $logoFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $logoFileModel->name; file_put_contents($logoFilePath, $logoFileModel->fileContent->content, LOCK_EX); ZurmoConfigurationFormAdapter::publishLogo($logoFileModel->name, $logoFilePath); } else { //Logo File exist in runtime/uploads but not published Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.runtime.uploads') . DIRECTORY_SEPARATOR . $logoFileModel->name); } } } }
public function actionConfigurationEdit() { $breadCrumbLinks = array(Zurmo::t('ZurmoModule', 'Global Configuration')); $configurationForm = ZurmoConfigurationFormAdapter::makeFormFromGlobalConfiguration(); $postVariableName = get_class($configurationForm); if (isset($_POST[$postVariableName])) { $configurationForm->setAttributes($_POST[$postVariableName]); if ($configurationForm->validate()) { ZurmoConfigurationFormAdapter::setConfigurationFromForm($configurationForm); Yii::app()->user->setFlash('notification', Zurmo::t('ZurmoModule', 'Global configuration saved successfully.')); $this->redirect(Yii::app()->createUrl('configuration/default/index')); } } $editView = new ZurmoConfigurationEditAndDetailsView('Edit', $this->getId(), $this->getModule()->getId(), $configurationForm); $editView->setCssClasses(array('AdministrativeArea')); $view = new ZurmoConfigurationPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $editView, $breadCrumbLinks, 'SettingsBreadCrumbView')); echo $view->render(); }
public function actionUploadLogo($filesVariableName) { assert('is_string($filesVariableName)'); try { $uploadedFile = CUploadedFile::getInstanceByName($filesVariableName); assert('$uploadedFile instanceof CUploadedFile'); $logoFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $uploadedFile->getName(); $thumbFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . ZurmoConfigurationForm::LOGO_THUMB_FILE_NAME_PREFIX . $uploadedFile->getName(); $uploadedFile->saveAs($logoFilePath); ZurmoConfigurationFormAdapter::resizeLogoImageFile($logoFilePath, $thumbFilePath, ZurmoConfigurationForm::DEFAULT_LOGO_THUMBNAIL_WIDTH, ZurmoConfigurationForm::DEFAULT_LOGO_THUMBNAIL_HEIGHT); Yii::app()->user->setState('logoFileName', $uploadedFile->getName()); $logoFileData = array('name' => $uploadedFile->getName(), 'type' => $uploadedFile->getType(), 'size' => $uploadedFile->getSize(), 'thumbnail_url' => Yii::app()->createUrl('zurmo/default/thumbnail/', array('filePath' => $thumbFilePath))); } catch (FailedFileUploadException $e) { $logoFileData = array('error' => Zurmo::t('ZurmoModule', 'Error') . ' ' . $e->getMessage()); } echo CJSON::encode(array($logoFileData)); Yii::app()->end(0, false); }