/** * Gets array for stages * @return array */ protected function getStageDropDownArray() { $customFieldData = CustomFieldData::getByName('ProductStages'); $customFieldIndexedData = CustomFieldDataUtil::getDataIndexedByDataAndTranslatedLabelsByLanguage($customFieldData, Yii::app()->language); $data = array_merge(array(ProductsConfigurationForm::FILTERED_BY_ALL_STAGES => Zurmo::t('Core', 'All')), $customFieldIndexedData); return $data; }
public function run() { $defaultView = $this->defaultView; $inputId = $this->inputId; $eventsUrl = Yii::app()->createUrl('calendars/default/getEvents'); //Set the goto date for calendar $startDate = $this->startDate; $startDateAttr = explode('-', $startDate); $year = $startDateAttr[0]; $month = intval($startDateAttr[1]) - 1; $day = intval($startDateAttr[2]); $currentYear = date('Y'); $currentMonth = intval(date('m')) - 1; $currentDay = date('d'); $maxCount = CalendarItemsDataProvider::MAXIMUM_CALENDAR_ITEMS_COUNT; //Register full calendar script and css self::registerFullCalendarScriptAndCss(); //Register qtip for event render $qtip = new ZurmoTip(); $qtip->addQTip(".fc-event"); $cs = Yii::app()->getClientScript(); $loadingText = Zurmo::t('Core', 'Loading..'); // Begin Not Coding Standard $script = "\$(document).on('ready', function() {\n \$('#{$inputId}').fullCalendar({\n editable: false,\n header: {\n left: 'prev,next today',\n center: 'title',\n right: 'month,basicWeek,basicDay'\n },\n defaultView: '{$defaultView}',\n firstDay :1,\n ignoreTimeZone:false,\n lazyFetching : false,\n loading: function(bool)\n {\n if (bool)\n {\n \$(this).makeLargeLoadingSpinner(true, '#{$inputId}');\n }\n else\n {\n \$(this).makeLargeLoadingSpinner(false, '#{$inputId}');\n }\n },\n eventSources: [\n getCalendarEvents('{$eventsUrl}', '{$inputId}')\n ],\n eventRender: function(event, element, view) {\n element.qtip({\n content: {\n text: '{$loadingText}',\n ajax: {\n url: event.description,\n type: 'get'\n },\n title: {\n text: event.title,\n button: 'Close'\n }\n },\n style: {classes:'calendar-event-tooltip'},\n show:{\n event: 'click'\n },\n hide: {\n event: 'false'\n },\n position: {\n my: 'bottom center',\n at: 'top center',\n target: 'mouse',\n viewport: \$('#calendar'),\n adjust: {\n mouse: false,\n scroll: false\n }\n }\n });\n },\n timeFormat: {\n 'month' : '',\n 'basicDay': 'h:mm-{h:mm}tt',\n 'basicWeek': 'h:mm-{h:mm}tt'\n }\n });\n \$('#{$inputId}').fullCalendar('gotoDate', {$year}, {$month}, {$day});\n \$('.fc-button-today').click(function() {\n \$('#{$inputId}').fullCalendar('changeView', 'basicDay');\n \$('#{$inputId}').fullCalendar('gotoDate', {$currentYear}, {$currentMonth}, {$currentDay});\n });\n });"; // End Not Coding Standard $cs->registerScript('loadCalendarScript', $script, ClientScript::POS_END); }
public function testApiServerUrl() { if (!$this->isApiTestUrlConfigured()) { $this->markTestSkipped(Zurmo::t('ApiModule', 'API test url is not configured in perInstanceTest.php file.')); } $this->assertTrue(strlen($this->serverUrl) > 0); }
/** * When the scenario is createNonDraft, it means you have to have at least one recipient * @param string $attribute * @param array $params */ public function validateMinimumToRecipients($attribute, $params) { if (isset($this->recipientsData['to']) && $this->recipientsData['to'] != null) { return; } $this->addError($attribute . '_to', Zurmo::t('EmailMessagesModule', 'To address cannot be blank')); }
/** * Override to handle scenarios where the application can detect apache is installed, but is unable to resolve * the version. * @see ServiceHelper::checkServiceAndSetMessagesByMethodNameAndDisplayLabel() */ protected function checkServiceAndSetMessagesByMethodNameAndDisplayLabel($methodName, $displayLabel) { assert('$this->minimumVersion != null && (is_array($this->minimumVersion) || is_string($this->minimumVersion))'); assert('is_string($methodName)'); assert('is_string($displayLabel)'); $actualVersion = null; $minimumVersionLabel = $this->getMinimumVersionLabel(); $passed = $this->callCheckServiceMethod($methodName, $actualVersion); if ($passed) { $this->message = $displayLabel . ' ' . Zurmo::t('InstallModule', 'version installed:') . ' ' . $actualVersion; $this->message .= ' ' . Zurmo::t('InstallModule', 'Minimum version required:') . ' ' . $minimumVersionLabel; return true; } else { if ($actualVersion == null) { if ($_SERVER['SERVER_SOFTWARE'] == 'Apache') { $this->checkResultedInWarning = true; $this->message = $displayLabel . ' ' . Zurmo::t('InstallModule', 'is installed, but the version is unknown.'); } else { $this->message = $displayLabel . ' ' . Zurmo::t('InstallModule', 'is not installed.'); } } else { $this->message = $displayLabel . ' ' . Zurmo::t('InstallModule', 'version installed:') . ' ' . $actualVersion; } $this->message .= "\n"; $this->message .= Zurmo::t('InstallModule', 'Minimum version required:') . ' ' . $minimumVersionLabel; return false; } }
/** * Override to ensure label is pointing to the right input id * @return A string containing the element's label */ protected function renderLabel() { if ($this->form === null) { throw new NotImplementedException(); } return ZurmoHtml::tag('h3', array(), Zurmo::t('ImportModule', 'Please select the module you would like to import to:')); }
protected static function makeForExplicitReadWriteModelPermissions($resolvedModelClassName) { assert('is_string($resolvedModelClassName)'); $form = new ExplicitReadWriteModelPermissionsWorkflowActionAttributeForm($resolvedModelClassName, 'permissions'); $form->setDisplayLabel(Zurmo::t('ZurmoModule', 'Who can read and write')); return $form; }
public function testSendSystemEmail() { if (!EmailMessageTestHelper::isSetEmailAccountsTestConfiguration()) { $this->markTestSkipped(Zurmo::t('EmailMessagesModule', 'Test email settings are not configured in perInstanceTest.php file.')); } $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; Yii::app()->imap->connect(); EmailMessage::deleteAll(); // Expunge all emails from dropbox Yii::app()->imap->deleteMessages(true); $this->assertEquals(0, EmailMessage::getCount()); $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed(); $this->assertEquals(0, $imapStats->Nmsgs); $subject = "System Message"; $textMessage = "System message content."; $htmlMessage = "<strong>System</strong> message content."; EmailMessageHelper::sendSystemEmail($subject, array(Yii::app()->imap->imapUsername), $textMessage, $htmlMessage); sleep(30); Yii::app()->imap->connect(); $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed(); $this->assertEquals(1, $imapStats->Nmsgs); $this->assertEquals(1, EmailMessage::getCount()); $emailMessages = EmailMessage::getAll(); $emailMessage = $emailMessages[0]; $this->assertEquals('System Message', $emailMessage->subject); $this->assertEquals('System message content.', trim($emailMessage->content->textContent)); $this->assertEquals('<strong>System</strong> message content.', trim($emailMessage->content->htmlContent)); $this->assertEquals(1, count($emailMessage->recipients)); foreach ($emailMessage->recipients as $recipient) { $this->assertEquals($recipient->toAddress, Yii::app()->imap->imapUsername); $this->assertEquals(EmailMessageRecipient::TYPE_TO, $recipient->type); } }
protected function resolveNextPagingAndParams($page, $params) { assert('$params === null || is_array($params)'); $pageCount = $this->dataProvider->getPagination()->getPageCount(); $pageSize = $this->dataProvider->getPagination()->getPageSize(); $totalItemCount = $this->dataProvider->getTotalItemCount(); $this->subSequenceCompletionPercentage = ($page + 1) / $pageCount * 100; if ($page + 1 == $pageCount) { $this->nextStep = 'complete'; $this->setNextMessageByStep($this->nextStep); return null; } else { $params['page'] = $page + 1; $this->nextStep = 'processRows'; $this->setNextMessageByStep($this->nextStep); $startItemCount = ($page + 1) * $pageSize + 1; if ($startItemCount + ($pageSize - 1) > $totalItemCount) { $endItemCount = $totalItemCount; } else { $endItemCount = ($page + 2) * $pageSize; } $labelParams = array('{startItemCount}' => $startItemCount, '{endItemCount}' => $endItemCount, '{totalItemCount}' => $totalItemCount); $nextMessage = ' ' . Zurmo::t('ImportModule', 'Record(s) {startItemCount} - {endItemCount} of {totalItemCount}', $labelParams); $this->nextMessage .= $nextMessage; return $params; } }
/** * If the attribute specified is required and the value is null, attempt to utilize a default value if it is * specified. If it is not specified or the default value specified is not a valid custom field data value, then * an InvalidValueToSanitizeException will be thrown. * @param string $modelClassName * @param string $attributeName * @param mixed $value * @param array $mappingRuleData */ public static function sanitizeValue($modelClassName, $attributeName, $value, $mappingRuleData) { assert('is_string($modelClassName)'); assert('is_string($attributeName)'); if ($value != null) { return $value; } assert('$value == null || $value instanceof OwnedCustomField'); assert('$mappingRuleData["defaultValue"] == null || is_string($mappingRuleData["defaultValue"])'); if ($mappingRuleData['defaultValue'] != null) { try { $customField = new OwnedCustomField(); $customField->value = $mappingRuleData['defaultValue']; $customField->data = CustomFieldDataModelUtil::getDataByModelClassNameAndAttributeName($modelClassName, $attributeName); } catch (NotSupportedException $e) { throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Pick list is missing corresponding custom field data.')); } return $customField; } else { $model = new $modelClassName(false); if (!$model->isAttributeRequired($attributeName)) { return $value; } throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Pick list value required, but missing.')); } return $value; }
/** * Render a test button. This link calls a modal popup. * @return The element's content as a string. */ protected function renderTestButton() { $content = '<span>'; $content .= ZurmoHtml::ajaxLink(ZurmoHtml::wrapLabel(Zurmo::t('EmailMessagesModule', 'Send Test Email')), Yii::app()->createUrl('sendGrid/default/sendTestMessage/', array()), static::resolveAjaxOptionsForTestEmailSettings($this->form->getId()), array('id' => 'SendATestEmailToButton', 'class' => 'EmailTestingButton z-button')); $content .= '</span>'; return $content; }
public function filters() { if (!YII_DEBUG) { echo Zurmo::t('ZurmoModule', 'This action is only available in debug mode.'); Yii::app()->end(0, false); } }
public function setUp() { parent::setUp(); if (!SendGridTestHelper::isSetSendGridAccountTestConfiguration()) { $this->markTestSkipped(Zurmo::t('SendGridModule', 'Email test settings are missing.')); } }
public function __toString() { $s = self::rightToString($this->type); $s .= ':'; $s .= Zurmo::t('ZurmoModule', $this->name); return $s; }
/** * @return array */ protected function getTypeData() { $categories = array(); $categories['clearCache'][] = array('titleLabel' => Zurmo::t('WorkflowsModule', 'On-Save Workflow'), 'route' => 'workflows/default/create?type=' . Workflow::TYPE_ON_SAVE); $categories['clearCache'][] = array('titleLabel' => Zurmo::t('WorkflowsModule', 'Time-Based Workflow'), 'route' => 'workflows/default/create?type=' . Workflow::TYPE_BY_TIME); return $categories; }
/** * Once the import is complete when using getData in ImportUtil::importByDataProvider, this can be called * to provide the final count. */ public function countDataProviderGetDataImportCompleted() { if ($this->messageStreamer != null) { $this->messageStreamer->addIgnoringTemplate("\n"); } $this->add(array(MessageLogger::INFO, Zurmo::t('ImportModule', 'Import complete. Rows processed: {rowsProcessed}', array('{rowsProcessed}' => $this->rowCount)))); }
protected function renderContent() { $message = Zurmo::t('ZurmoModule', 'Sorry! Your browser is not supported.') . ' ' . Zurmo::t('ZurmoModule', 'Please use FireFox, Chrome, or Internet Explorer.'); $message = Yii::app()->format->text($message); $content = "<div>{$message}</div><!-- Detected: {$this->browserName} -->"; return $content; }
/** * Renders title content. * @return string */ protected function renderTitleContent() { $title = ZurmoHtml::tag('h3', array(), Zurmo::t('CalendarsModule', 'My Calendars')); $link = ZurmoHtml::link(ZurmoHtml::tag('span', array('class' => 'z-label'), 'Y'), Yii::app()->createUrl('/calendars/default/create'), array('class' => 'white-button')); $content = ZurmoHtml::tag('div', array('class' => 'cal-list-header clearfix'), $title . $link); return $content; }
public function __toString() { if (trim($this->member) == '') { return Zurmo::t('Core', '(Unnamed)'); } return $this->member; }
protected function renderContent() { $imagePath = Yii::app()->themeManager->baseUrl . '/default/images/ajax-loader.gif'; $progressBarImageContent = ZurmoHtml::image($imagePath, 'Progress Bar'); $cs = Yii::app()->getClientScript(); $cs->registerScriptFile($cs->getCoreScriptUrl() . '/jquery.min.js', CClientScript::POS_END); $loginUrl = Yii::app()->createUrl('zurmo/default'); $content = '<div class="MetadataView">'; $content .= '<table><tr><td>'; $content .= '<div id="complete-table" style="display:none;">'; $content .= '<table><tr><td>'; $content .= Zurmo::t('InstallModule', 'Congratulations! The demo data has been successfully loaded.'); $content .= '<br/>'; $content .= '<br/>'; $content .= Zurmo::t('InstallModule', 'Click below to go to the login page. The username is <b>super</b>'); $content .= '<br/><br/>'; $content .= ZurmoHtml::link(Zurmo::t('ZurmoModule', 'Sign in'), $loginUrl); $content .= '</td></tr></table>'; $content .= '</div>'; $content .= '<div id="progress-table">'; $content .= '<table><tr><td class="progress-bar">'; $content .= Zurmo::t('InstallModule', 'Loading demo data. Please wait.'); $content .= '<br/>'; $content .= $progressBarImageContent; $content .= '<br/>'; $content .= '</td></tr></table>'; $content .= '</div>'; $content .= Zurmo::t('InstallModule', 'Installation Output:'); $content .= '<div id="logging-table">'; $content .= '</div>'; $content .= '</td></tr></table>'; $content .= '</div>'; return $content; }
protected function renderActionBarContent() { $currentPageUrl = Yii::app()->createUrl($this->moduleId . '/' . $this->controllerId . '/runDiagnostic/'); $content = '<br/><br/>'; $content .= ZurmoHtml::link(ZurmoHtml::wrapLabel(Zurmo::t('InstallModule', 'Recheck System')), $currentPageUrl, array('class' => 'z-button')); return $content; }
/** * Override to change the editableTemplate to place the label above the input. * @see DetailsView::resolveElementDuringFormLayoutRender() */ protected function resolveElementDuringFormLayoutRender(&$element) { if ($element->getAttribute() == 'name') { $notification = ZurmoHtml::tag('span', array('class' => 'row-description'), Zurmo::t('MarketingListsModule', 'Name will be publicly viewable by Contacts/Leads to manage their subscriptions')); $element->editableTemplate = '<th>{label}</th><td colspan="{colspan}">{content}' . $notification . '{error}</td>'; } }
/** * Check if the required runtime folders are present and writable i.e. (assets , runtime and data) * @returns true, if the required folders are present, or false if not installed. If returning * false, populates the $message property accordingly. */ protected function checkService() { $passed = true; $pathsToTest = array(INSTANCE_ROOT . '/assets', INSTANCE_ROOT . '/protected/data', INSTANCE_ROOT . '/protected/runtime'); foreach ($pathsToTest as $pathToTest) { if (!file_exists($pathToTest)) { if ($this->message != null) { $this->message .= "\n"; } $this->message .= Zurmo::t('InstallModule', '{folderPath} is missing.', array('{folderPath}' => $pathToTest)); $passed = false; } if (!is_writable($pathToTest)) { if ($this->message != null) { $this->message .= "\n"; } $this->message .= Zurmo::t('InstallModule', '{folderPath} is not writable.', array('{folderPath}' => $pathToTest)); $passed = false; } } if ($passed) { $this->message .= Zurmo::t('InstallModule', 'The instance folders are present and writable.'); } return $passed; }
/** * If the attribute specified is required and the value is null, attempt to utilize a default value if it is * specified. If it is not specified or the default value specified is not a valid custom field data value, then * an InvalidValueToSanitizeException will be thrown. * @param mixed $value * @return sanitized value * @throws InvalidValueToSanitizeException */ public function sanitizeValue($value) { if ($value != null) { return $value; } assert('$value == null || $value instanceof OwnedMultipleValuesCustomField'); if (isset($this->mappingRuleData['defaultValue']) && $this->mappingRuleData['defaultValue'] != null) { try { $customField = new OwnedMultipleValuesCustomField(); foreach ($this->mappingRuleData['defaultValue'] as $aDefaultValue) { $customFieldValue = new CustomFieldValue(); $customFieldValue->value = $aDefaultValue; $customField->values->add($customFieldValue); } $customField->data = CustomFieldDataModelUtil::getDataByModelClassNameAndAttributeName($this->modelClassName, $this->attributeName); } catch (NotSupportedException $e) { throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Pick list is missing corresponding custom field data.')); } return $customField; } else { $modelClassName = $this->modelClassName; $model = new $modelClassName(false); if (!$model->isAttributeRequired($this->attributeName)) { return $value; } throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', 'Pick list value required, but missing.')); } }
protected function getMessageContent() { $message = Zurmo::t('Core', 'There are no more portlets to add'); $content = ZurmoHtml::tag('span', array('class' => 'icon-notice'), ''); $content .= ZurmoHtml::tag('p', array(), $message); return $content; }
/** * Given a value that is either a zurmo id or an external system id, resolve that the * value is valid. If the value is not valid then an InvalidValueToSanitizeException is thrown. * @param mixed $value * @return sanitized value * @throws InvalidValueToSanitizeException * @throws NotFoundException */ public function sanitizeValue($value) { assert('$this->attributeName == null'); $derivedModelClassName = static::getDerivedModelClassName(); if ($value == null) { return $value; } if ($this->mappingRuleData["type"] == IdValueTypeMappingRuleForm::ZURMO_MODEL_ID) { try { if ((int) $value <= 0) { throw new NotFoundException(); } return $derivedModelClassName::getById((int) $value); } catch (NotFoundException $e) { $derivedModelClassName = static::getDerivedModelClassName(); $modelLabel = $derivedModelClassName::getModelLabelByTypeAndLanguage('Singular'); throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', '{modelLabel} ID specified did not match any existing records.', array('{modelLabel}' => $modelLabel))); } } elseif ($this->mappingRuleData["type"] == IdValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID) { try { return static::getModelByExternalSystemIdAndModelClassName($value, $derivedModelClassName); } catch (NotFoundException $e) { $derivedModelClassName = static::getDerivedModelClassName(); $modelLabel = $derivedModelClassName::getModelLabelByTypeAndLanguage('Singular'); throw new InvalidValueToSanitizeException(Zurmo::t('ImportModule', '{modelLabel} other ID specified did not match any existing records.', array('{modelLabel}' => $modelLabel))); } } }
/** * @return string */ protected function renderEditableSecondValueContent() { $htmlOptions = $this->getHtmlOptionsForSecondValue(); $inputContent = $this->form->textField($this->model, 'value', $htmlOptions); $error = $this->form->error($this->model, 'value', array('inputID' => $this->getSecondValueEditableInputId()), true, true, $this->getSecondValueEditableInputId()); return $inputContent . $error . ZurmoHtml::tag('span', array(), ' ' . Zurmo::t('WorkflowsModule', 'value(s)')); }
/** * @return string|void */ protected function renderBeforeFormLayoutForDetailsContent() { $embedScript = '<div id="zurmoExternalWebForm">' . '<script type="text/javascript" ' . 'src="' . Yii::app()->createAbsoluteUrl('contacts/external/sourceFiles/', array('id' => $this->model->id)) . '">' . '</script></div>'; $title = ZurmoHtml::tag('h3', array(), Zurmo::t('ContactWebFormsModule', 'Copy/Paste this code to your web page..')); return '<div class="webform-embed-code">' . $title . '<textarea onclick="this.focus();this.select()" readonly="readonly">' . htmlspecialchars($embedScript) . '</textarea></div>'; }
protected static function resolveConfiguration() { $configurationItems = array(); $configurationItems[] = static::resolveConfigurationItem('BuilderElementBackendPropertiesEditableElementUtil', 'FancyDividerStyleRadioElement', 'image', static::resolveDefaultParams(Zurmo::t('EmailTemplatesModule', 'Style'))); $configurationItems[] = static::resolveConfigurationItem('BuilderElementBackendPropertiesEditableElementUtil', 'TextElement', 'divider-padding', static::resolveDefaultParams(Zurmo::t('EmailTemplatesModule', 'Padding'))); return $configurationItems; }
/** * Runs a query to get all the dates for meetings based on SearchAttributeData. Then the data is processed * and @returns a data array of dates and quantity. Quantity stands for how many meetings in a given date. * (non-PHPdoc) * @see CalendarDataProvider::getData() */ public function getData() { $sql = $this->makeSqlQuery(); $rows = ZurmoRedBean::getAll($sql); $data = array(); foreach ($rows as $row) { $localTimeZoneAdjustedDate = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($row['startdatetime'], 'medium', null); if (isset($data[$localTimeZoneAdjustedDate])) { $data[$localTimeZoneAdjustedDate]['quantity'] = $data[$localTimeZoneAdjustedDate]['quantity'] + 1; } else { $data[$localTimeZoneAdjustedDate] = array('date' => $localTimeZoneAdjustedDate, 'quantity' => 1, 'dbDate' => $row['startdatetime']); } } foreach ($data as $key => $item) { if ($item['quantity'] == 1) { $label = Zurmo::t('MeetingsModule', '{quantity} MeetingsModuleSingularLabel', array_merge(LabelUtil::getTranslationParamsForAllModules(), array('{quantity}' => $item['quantity']))); } else { $label = Zurmo::t('MeetingsModule', '{quantity} MeetingsModulePluralLabel', array_merge(LabelUtil::getTranslationParamsForAllModules(), array('{quantity}' => $item['quantity']))); } $data[$key]['label'] = $label; if ($item['quantity'] > 5) { $quantityClassSuffix = 6; } else { $quantityClassSuffix = $item['quantity']; } $data[$key]['className'] = 'calendar-events-' . $quantityClassSuffix; } return $data; }