/**
  * Get starting page uid
  *      current pid or given pid from Page TSConfig
  *
  * @return int
  */
 protected function getStartPid()
 {
     $tsConfiguration = BackendUtility::getPagesTSconfig(BackendUtility::getPidFromBackendPage());
     $startPid = 0;
     if (!empty($tsConfiguration['tx_powermail.']['flexForm.']['formSelection'])) {
         $startPid = $tsConfiguration['tx_powermail.']['flexForm.']['formSelection'];
         if ($startPid === 'current') {
             $startPid = BackendUtility::getPidFromBackendPage();
         }
     }
     return (int) $startPid;
 }
 /**
  * Create Field Record
  *
  * @param array $form
  * @param int $pageUid
  * @param array $field
  * @param int $formCounter
  * @param int $pageCounter
  * @param int $fieldCounter
  * @return void
  */
 protected function createFieldRecord($form, $pageUid, $field, $formCounter, $pageCounter, $fieldCounter)
 {
     $fieldProperties = ['uid' => 0, 'pid' => $this->configuration['save'] === '[samePage]' ? $form['pid'] : (int) $this->configuration['save'], 'pages' => $pageUid, 'title' => $field['title'], 'type' => $this->rewriteFormType($field), 'css' => $this->rewriteStyles($field), 'cruser_id' => BackendUtility::getPropertyFromBackendUser(), 'hidden' => $field['hidden'], 'sorting' => $field['sorting'], 'marker' => $this->getMarker($field), 'settings' => $field['options'], 'path' => $this->getValueIfDefaultLanguage($field, 'path'), 'content_element' => $field['path'], 'text' => $field['value'], 'placeholder' => $field['placeholder'], 'description' => $field['description'], 'prefill_value' => $this->getPrefillValue($field), 'feuser_value' => $this->getValueIfDefaultLanguage($field, 'fe_field'), 'mandatory' => $this->getValueIfDefaultLanguage($field, 'mandatory'), 'validation' => $this->rewriteValidation($field), 'validation_configuration' => $this->rewriteValidationConfiguration($field), 'datepicker_settings' => $this->getDatePickerSettings($field), 'multiselect' => $this->getValueIfDefaultLanguage($field, 'multiple'), 'sender_email' => $this->isSenderEmail($form, $field), 'sender_name' => $this->isSenderName($form, $field), 'tstamp' => time(), 'crdate' => time()];
     if ($field['sys_language_uid'] > 0) {
         $fieldProperties['sys_language_uid'] = $field['sys_language_uid'];
         $fieldProperties['l10n_parent'] = (int) $this->localizationRelations['field'][$field['l18n_parent']];
     }
     if (!$this->isDryrun()) {
         $this->getDatabaseConnection()->exec_INSERTquery('tx_powermail_domain_model_fields', $fieldProperties);
         $fieldProperties['uid'] = $this->getDatabaseConnection()->sql_insert_id();
         $this->localizationRelations['field'][$field['uid']] = $fieldProperties['uid'];
     }
     $this->result[$formCounter]['_pages'][$pageCounter]['_fields'][$fieldCounter] = $fieldProperties;
 }
 /**
  * Build URI for edit link
  *
  * @param int $formUid
  * @return string
  */
 protected function getEditFormLink($formUid)
 {
     return BackendUtility::createEditUri('tx_powermail_domain_model_forms', $formUid);
 }
 /**
  * Is Backend Admin?
  *
  * @return bool
  */
 public function render()
 {
     return BackendUtility::isBackendAdmin();
 }
 /**
  * Check if admin is logged in
  *        If not, forward to tools overview
  *
  * @return void
  */
 protected function checkAdminPermissions()
 {
     if (!BackendUtility::isBackendAdmin()) {
         $this->controllerContext = $this->buildControllerContext();
         $this->forward('toolsBe');
     }
 }
 /**
  * Build edit link
  *
  * @return string
  */
 protected function buildEditFormLink()
 {
     return BackendUtility::createEditUri('tx_powermail_domain_model_forms', $this->getFormProperty($this->getFieldFromFlexform('main', 'main.form'), 'uid'));
 }
 /**
  * Extend dataType with TSConfig
  *
  * @param string $fieldType
  * @param array $types
  * @return array
  */
 protected function extendTypeArrayWithTypoScriptTypes($fieldType, array $types)
 {
     $typoScript = BackendUtility::getPagesTSconfig(FrontendUtility::getCurrentPageIdentifier());
     $configuration = $typoScript['tx_powermail.']['flexForm.'];
     if (!empty($configuration['type.']['addFieldOptions.'][$fieldType . '.']['dataType'])) {
         $types[$fieldType] = (int) $configuration['type.']['addFieldOptions.'][$fieldType . '.']['dataType'];
     }
     return $types;
 }
 /**
  * isBackendAdmin Test
  *
  * @param string $value
  * @param bool $expectedResult
  * @dataProvider isBackendAdminReturnsBoolDataProvider
  * @return void
  * @test
  */
 public function isBackendAdminReturnsBool($value, $expectedResult)
 {
     $GLOBALS['BE_USER']->user['admin'] = $value;
     $this->assertSame($expectedResult, BackendUtility::isBackendAdmin());
 }
 /**
  * Get commaseparated list of PID under a starting Page
  *
  * @param int|string $startPid Integer or "current"
  * @return string
  */
 protected function getPidListFromStartingPoint($startPid = 0)
 {
     /** @var \TYPO3\CMS\Core\Database\QueryGenerator $queryGenerator */
     $queryGenerator = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\QueryGenerator');
     if ($startPid === 'current') {
         $startPid = BackendUtility::getPidFromBackendPage();
     }
     $list = $queryGenerator->getTreeList($startPid, 10, 0, 1);
     return $list;
 }
 /**
  * Create a link for backend edit
  *
  * @param string $tableName
  * @param int $identifier
  * @param bool $addReturnUrl
  * @return string
  */
 public function render($tableName, $identifier, $addReturnUrl = true)
 {
     return BackendUtility::createEditUri($tableName, $identifier, $addReturnUrl);
 }
 /**
  * getPidFromBackendPage Test
  *
  * @param string $returnUrl
  * @param int $expectedResult
  * @dataProvider getPidFromBackendPageReturnsIntDataProvider
  * @return void
  * @test
  */
 public function getPidFromBackendPageReturnsInt($returnUrl, $expectedResult)
 {
     $this->assertSame($expectedResult, BackendUtility::getPidFromBackendPage($returnUrl));
 }