Ejemplo n.º 1
0
 /**
  * Initializing global variables
  *
  * @return	void
  */
 function init()
 {
     $this->MCONF = $GLOBALS['MCONF'];
     parent::init();
     // initialize IconFactory
     $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     $temp = BackendUtility::getModTSconfig($this->id, 'mod.web_modules.dmail');
     if (!is_array($temp['properties'])) {
         $temp['properties'] = array();
     }
     $this->params = $temp['properties'];
     $this->implodedParams = DirectMailUtility::implodeTSParams($this->params);
     if ($this->params['userTable'] && is_array($GLOBALS["TCA"][$this->params['userTable']])) {
         $this->userTable = $this->params['userTable'];
         $this->allowedTables[] = $this->userTable;
     }
     $this->MOD_MENU['dmail_mode'] = BackendUtility::unsetMenuItems($this->params, $this->MOD_MENU['dmail_mode'], 'menu.dmail_mode');
     // initialize backend user language
     if ($this->getLanguageService()->lang && ExtensionManagementUtility::isLoaded('static_info_tables')) {
         $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('sys_language.uid', 'sys_language LEFT JOIN static_languages ON sys_language.static_lang_isocode=static_languages.uid', 'static_languages.lg_typo3=' . $GLOBALS["TYPO3_DB"]->fullQuoteStr($this->getLanguageService()->lang, 'static_languages') . BackendUtility::BEenableFields('sys_language') . BackendUtility::deleteClause('sys_language') . BackendUtility::deleteClause('static_languages'));
         while ($row = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res)) {
             $this->sys_language_uid = $row['uid'];
         }
         $GLOBALS["TYPO3_DB"]->sql_free_result($res);
     }
     // load contextual help
     $this->cshTable = '_MOD_' . $this->MCONF['name'];
     if ($GLOBALS["BE_USER"]->uc['edit_showFieldHelp']) {
         $this->getLanguageService()->loadSingleTableDescription($this->cshTable);
     }
 }
 /**
  * Updates Page TSconfig for a page with $id
  * The function seems to take $pageTS as an array with properties
  * and compare the values with those that already exists for the "object string",
  * $TSconfPrefix, for the page, then sets those values which were not present.
  * $impParams can be supplied as already known Page TSconfig, otherwise it's calculated.
  *
  * THIS DOES NOT CHECK ANY PERMISSIONS. SHOULD IT?
  * More documentation is needed.
  *
  * @param int $id Page id
  * @param array $pageTs Page TS array to write
  * @param string $tsConfPrefix Prefix for object paths
  * @param array|string $impParams [Description needed.]
  *
  * @return	void
  *
  * @see implodeTSParams(), getPagesTSconfig()
  */
 public static function updatePagesTSconfig($id, array $pageTs, $tsConfPrefix, $impParams = '')
 {
     $id = intval($id);
     if (is_array($pageTs) && $id > 0) {
         if (!is_array($impParams)) {
             $impParams = DirectMailUtility::implodeTSParams(BackendUtility::getPagesTSconfig($id));
         }
         $set = array();
         foreach ($pageTs as $f => $v) {
             $f = $tsConfPrefix . $f;
             if (!isset($impParams[$f]) && trim($v) || strcmp(trim($impParams[$f]), trim($v))) {
                 $set[$f] = trim($v);
             }
         }
         if (count($set)) {
             // Get page record and TS config lines
             $pRec = BackendUtility::getRecord('pages', $id);
             $tsLines = explode(LF, $pRec['TSconfig']);
             $tsLines = array_reverse($tsLines);
             // Reset the set of changes.
             foreach ($set as $f => $v) {
                 $inserted = 0;
                 foreach ($tsLines as $ki => $kv) {
                     if (substr($kv, 0, strlen($f) + 1) == $f . '=') {
                         $tsLines[$ki] = $f . '=' . $v;
                         $inserted = 1;
                         break;
                     }
                 }
                 if (!$inserted) {
                     $tsLines = array_reverse($tsLines);
                     $tsLines[] = $f . '=' . $v;
                     $tsLines = array_reverse($tsLines);
                 }
             }
             $tsLines = array_reverse($tsLines);
             // store those changes
             $tsConf = implode(LF, $tsLines);
             $GLOBALS['TYPO3_DB']->exec_UPDATEquery('pages', 'uid=' . intval($id), array('TSconfig' => $tsConf));
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * First initialization of global variables
  *
  * @return	void
  */
 public function init()
 {
     parent::init();
     // initialize IconFactory
     $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
     // get the config from pageTS
     $temp = BackendUtility::getModTSconfig($this->id, 'mod.web_modules.dmail');
     if (!is_array($temp['properties'])) {
         $temp['properties'] = array();
     }
     $this->params = $temp['properties'];
     $this->implodedParams = DirectMailUtility::implodeTSParams($this->params);
     if ($this->params['userTable'] && is_array($GLOBALS['TCA'][$this->params['userTable']])) {
         $this->userTable = $this->params['userTable'];
         $this->allowedTables[] = $this->userTable;
     }
     // check if the right domain shoud be set
     if (!$this->params['use_domain']) {
         $rootLine = BackendUtility::BEgetRootLine($this->id);
         if ($rootLine) {
             $parts = parse_url(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
             if (BackendUtility::getDomainStartPage($parts['host'], $parts['path'])) {
                 $temporaryPreUrl = BackendUtility::firstDomainRecord($rootLine);
                 $domain = BackendUtility::getRecordsByField('sys_domain', 'domainName', $temporaryPreUrl, ' AND hidden=0', '', 'sorting');
                 if (is_array($domain)) {
                     reset($domain);
                     $dom = current($domain);
                     $this->params['use_domain'] = $dom['uid'];
                 }
             }
         }
     }
     $this->MOD_MENU['dmail_mode'] = BackendUtility::unsetMenuItems($this->params, $this->MOD_MENU['dmail_mode'], 'menu.dmail_mode');
     // initialize backend user language
     if ($this->getLanguageService()->lang && ExtensionManagementUtility::isLoaded('static_info_tables')) {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('sys_language.uid', 'sys_language LEFT JOIN static_languages ON sys_language.static_lang_isocode=static_languages.uid', 'static_languages.lg_typo3=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->getLanguageService()->lang, 'static_languages') . BackendUtility::BEenableFields('sys_language') . BackendUtility::deleteClause('sys_language') . BackendUtility::deleteClause('static_languages'));
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $this->sys_language_uid = $row['uid'];
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
     }
     // load contextual help
     $this->cshTable = '_MOD_' . $this->MCONF['name'];
     if ($GLOBALS['BE_USER']->uc['edit_showFieldHelp']) {
         $this->getLanguageService()->loadSingleTableDescription($this->cshTable);
     }
 }