/** * Show the categories table for user to categorize the directmail content * TYPO3 content) * * @param array $row The dmail row. * * @return string HTML form showing the categories */ public function makeCategoriesForm(array $row) { $indata = GeneralUtility::_GP('indata'); if (is_array($indata['categories'])) { $data = array(); foreach ($indata['categories'] as $recUid => $recValues) { $enabled = array(); foreach ($recValues as $k => $b) { if ($b) { $enabled[] = $k; } } $data['tt_content'][$recUid]['module_sys_dmail_category'] = implode(',', $enabled); } /* @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */ $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); $tce->stripslashes_values = 0; $tce->start($data, array()); $tce->process_datamap(); // remove cache $tce->clear_cacheCmd($this->pages_uid); $out = DirectMailUtility::fetchUrlContentsForDirectMailRecord($row, $this->params); } // Todo Perhaps we should here check if TV is installed and fetch content from that instead of the old Columns... $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('colPos, CType, uid, pid, header, bodytext, module_sys_dmail_category', 'tt_content', 'pid=' . intval($this->pages_uid) . BackendUtility::deleteClause('tt_content') . BackendUtility::BEenableFields('tt_content'), '', 'colPos,sorting'); if (!$GLOBALS['TYPO3_DB']->sql_num_rows($res)) { $theOutput = $this->doc->section($this->getLanguageService()->getLL('nl_cat'), $this->getLanguageService()->getLL('nl_cat_msg1'), 1, 1, 0, true); } else { $out = ''; $colPosVal = 99; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $categoriesRow = ''; $resCat = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid_foreign', 'sys_dmail_ttcontent_category_mm', 'uid_local=' . $row['uid']); while ($rowCat = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resCat)) { $categoriesRow .= $rowCat['uid_foreign'] . ','; } $GLOBALS['TYPO3_DB']->sql_free_result($resCat); $categoriesRow = rtrim($categoriesRow, ','); if ($colPosVal != $row['colPos']) { $out .= '<tr><td colspan="3" bgcolor="' . $this->doc->bgColor5 . '">' . $this->getLanguageService()->getLL('nl_l_column') . ': <strong>' . BackendUtility::getProcessedValue('tt_content', 'colPos', $row['colPos']) . '</strong></td></tr>'; $colPosVal = $row["colPos"]; } $out .= '<tr>'; $out .= '<td valign="top" width="75%">' . $this->iconFactory->getIconForRecord('tt_content', $row, Icon::SIZE_SMALL) . $row['header'] . '<br />' . GeneralUtility::fixed_lgd_cs(strip_tags($row['bodytext']), 200) . '<br /></td>'; $out .= '<td nowrap valign="top">'; $checkBox = ''; if ($row['module_sys_dmail_category']) { $checkBox .= '<strong style="color:red;">' . $this->getLanguageService()->getLL('nl_l_ONLY') . '</strong>'; } else { $checkBox .= '<strong style="color:green">' . $this->getLanguageService()->getLL('nl_l_ALL') . '</strong>'; } $checkBox .= '<br />'; $this->categories = DirectMailUtility::makeCategories('tt_content', $row, $this->sys_language_uid); reset($this->categories); foreach ($this->categories as $pKey => $pVal) { $checkBox .= '<input type="hidden" name="indata[categories][' . $row["uid"] . '][' . $pKey . ']" value="0">' . '<input type="checkbox" name="indata[categories][' . $row['uid'] . '][' . $pKey . ']" value="1"' . (GeneralUtility::inList($categoriesRow, $pKey) ? ' checked' : '') . '> ' . htmlspecialchars($pVal) . '<br />'; } $out .= $checkBox . '</td></tr>'; } $GLOBALS['TYPO3_DB']->sql_free_result($res); $out = '<table border="0" cellpadding="0" cellspacing="0" class="table table-striped table-hover">' . $out . '</table>'; $out .= '<input type="hidden" name="pages_uid" value="' . $this->pages_uid . '">' . '<input type="hidden" name="CMD" value="' . $this->CMD . '"><br />' . '<input type="submit" name="update_cats" value="' . $this->getLanguageService()->getLL('nl_l_update') . '">'; $theOutput = $this->doc->section($this->getLanguageService()->getLL('nl_cat') . BackendUtility::cshItem($this->cshTable, 'assign_categories', $GLOBALS['BACK_PATH']), $out, 1, 1, 0, true); } return $theOutput; }
/** * Shows user's info and categories * * @return string HTML showing user's info and the categories */ function cmd_displayUserInfo() { $uid = intval(GeneralUtility::_GP('uid')); $indata = GeneralUtility::_GP('indata'); $table = GeneralUtility::_GP('table'); $mmTable = $GLOBALS["TCA"][$table]['columns']['module_sys_dmail_category']['config']['MM']; if (GeneralUtility::_GP('submit')) { $indata = GeneralUtility::_GP('indata'); if (!$indata) { $indata['html'] = 0; } } switch ($table) { case 'tt_address': // see fe_users // see fe_users case 'fe_users': if (is_array($indata)) { $data = array(); if (is_array($indata['categories'])) { reset($indata['categories']); foreach ($indata["categories"] as $recValues) { $enabled = array(); foreach ($recValues as $k => $b) { if ($b) { $enabled[] = $k; } } $data[$table][$uid]['module_sys_dmail_category'] = implode(',', $enabled); } } $data[$table][$uid]['module_sys_dmail_html'] = $indata['html'] ? 1 : 0; /* @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */ $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); $tce->stripslashes_values = 0; $tce->start($data, array()); $tce->process_datamap(); } break; default: // do nothing } switch ($table) { case 'tt_address': $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('tt_address.*', 'tt_address LEFT JOIN pages ON pages.uid=tt_address.pid', 'tt_address.uid=' . intval($uid) . ' AND ' . $this->perms_clause . BackendUtility::deleteClause('pages') . BackendUtility::BEenableFields('tt_address') . BackendUtility::deleteClause('tt_address')); break; case 'fe_users': $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('fe_users.*', 'fe_users LEFT JOIN pages ON pages.uid=fe_users.pid', 'fe_users.uid=' . intval($uid) . ' AND ' . $this->perms_clause . BackendUtility::deleteClause('pages') . BackendUtility::BEenableFields('fe_users') . BackendUtility::deleteClause('fe_users')); break; default: // do nothing } $row = array(); if ($res) { $row = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res); $GLOBALS["TYPO3_DB"]->sql_free_result($res); } $theOutput = ""; if (is_array($row)) { $categories = ''; $resCat = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('uid_foreign', $mmTable, 'uid_local=' . $row['uid']); while ($rowCat = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($resCat)) { $categories .= $rowCat['uid_foreign'] . ','; } $categories = rtrim($categories, ","); $GLOBALS["TYPO3_DB"]->sql_free_result($resCat); $editParameters = '&edit[' . $table . '][' . $row['uid'] . ']=edit'; $out = ''; $out .= $this->iconFactory->getIconForRecord($table, $row)->render() . htmlspecialchars($row['name'] . ' <' . $row['email'] . '>'); $out .= ' <a href="#" onClick="' . BackendUtility::editOnClick($editParameters, $GLOBALS["BACK_PATH"], '') . '" title="' . $this->getLanguageService()->getLL("dmail_edit") . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL) . $this->getLanguageService()->getLL('dmail_edit') . '</b></a>'; $theOutput = $this->doc->section($this->getLanguageService()->getLL('subscriber_info'), $out); $out = ''; $this->categories = DirectMailUtility::makeCategories($table, $row, $this->sys_language_uid); foreach ($this->categories as $pKey => $pVal) { $out .= '<input type="hidden" name="indata[categories][' . $row['uid'] . '][' . $pKey . ']" value="0" />' . '<input type="checkbox" name="indata[categories][' . $row['uid'] . '][' . $pKey . ']" value="1"' . (GeneralUtility::inList($categories, $pKey) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($pVal) . '<br />'; } $out .= '<br /><br /><input type="checkbox" name="indata[html]" value="1"' . ($row['module_sys_dmail_html'] ? ' checked="checked"' : '') . ' /> '; $out .= $this->getLanguageService()->getLL('subscriber_profile_htmlemail') . '<br />'; $out .= '<input type="hidden" name="table" value="' . $table . '" />' . '<input type="hidden" name="uid" value="' . $uid . '" />' . '<input type="hidden" name="CMD" value="' . $this->CMD . '" /><br />' . '<input type="submit" name="submit" value="' . htmlspecialchars($this->getLanguageService()->getLL('subscriber_profile_update')) . '" />'; $theOutput .= '<div style="padding-top: 20px;"></div>'; $theOutput .= $this->doc->section($this->getLanguageService()->getLL('subscriber_profile'), $this->getLanguageService()->getLL('subscriber_profile_instructions') . '<br /><br />' . $out); } return $theOutput; }
/** * shows user's info and categories * * @return string HTML showing user's info and the categories */ function cmd_displayUserInfo() { $uid = intval(GeneralUtility::_GP('uid')); $indata = GeneralUtility::_GP('indata'); $table = GeneralUtility::_GP('table'); $mm_table = $GLOBALS["TCA"][$table]['columns']['module_sys_dmail_category']['config']['MM']; if (GeneralUtility::_GP('submit')) { $indata = GeneralUtility::_GP('indata'); if (!$indata) { $indata['html'] = 0; } } switch ($table) { case 'tt_address': case 'fe_users': if (is_array($indata)) { $data = array(); if (is_array($indata['categories'])) { reset($indata['categories']); foreach ($indata["categories"] as $recValues) { $enabled = array(); while (list($k, $b) = each($recValues)) { if ($b) { $enabled[] = $k; } } $data[$table][$uid]['module_sys_dmail_category'] = implode(',', $enabled); } } $data[$table][$uid]['module_sys_dmail_html'] = $indata['html'] ? 1 : 0; /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */ $tce = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); $tce->stripslashes_values = 0; $tce->start($data, array()); $tce->process_datamap(); } break; } switch ($table) { case 'tt_address': $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('tt_address.*', 'tt_address LEFT JOIN pages ON pages.uid=tt_address.pid', 'tt_address.uid=' . intval($uid) . ' AND ' . $this->perms_clause . BackendUtility::deleteClause('pages') . BackendUtility::BEenableFields('tt_address') . BackendUtility::deleteClause('tt_address')); break; case 'fe_users': $res = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('fe_users.*', 'fe_users LEFT JOIN pages ON pages.uid=fe_users.pid', 'fe_users.uid=' . intval($uid) . ' AND ' . $this->perms_clause . BackendUtility::deleteClause('pages') . BackendUtility::BEenableFields('fe_users') . BackendUtility::deleteClause('fe_users')); break; } $row = array(); if ($res) { $row = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($res); $GLOBALS["TYPO3_DB"]->sql_free_result($res); } $theOutput = ""; if (is_array($row)) { $row_categories = ''; $resCat = $GLOBALS["TYPO3_DB"]->exec_SELECTquery('uid_foreign', $mm_table, 'uid_local=' . $row['uid']); while ($rowCat = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($resCat)) { $row_categories .= $rowCat['uid_foreign'] . ','; } $row_categories = rtrim($row_categories, ","); $GLOBALS["TYPO3_DB"]->sql_free_result($resCat); $Eparams = '&edit[' . $table . '][' . $row['uid'] . ']=edit'; $out = ''; $out .= IconUtility::getSpriteIconForRecord($table, $row, array('title' => BackendUtility::getRecordPath($row['pid'], $this->perms_clause, 40))) . htmlspecialchars($row['name'] . ' <' . $row['email'] . '>'); $out .= ' <a href="#" onClick="' . BackendUtility::editOnClick($Eparams, $GLOBALS["BACK_PATH"], '') . '"><img' . IconUtility::skinImg($GLOBALS["BACK_PATH"], 'gfx/edit2.gif', 'width="12" height="12"') . ' alt="' . $GLOBALS["LANG"]->getLL("dmail_edit") . '" width="12" height="12" style="margin: 2px 3px; vertical-align:top;" title="' . $GLOBALS["LANG"]->getLL("dmail_edit") . '" /><b>' . $GLOBALS["LANG"]->getLL('dmail_edit') . '</b></a>'; $theOutput = $this->doc->section($GLOBALS["LANG"]->getLL('subscriber_info'), $out); $out = ''; $out_check = ''; $this->categories = DirectMailUtility::makeCategories($table, $row, $this->sys_language_uid); foreach ($this->categories as $pKey => $pVal) { $out_check .= '<input type="hidden" name="indata[categories][' . $row['uid'] . '][' . $pKey . ']" value="0" /><input type="checkbox" name="indata[categories][' . $row['uid'] . '][' . $pKey . ']" value="1"' . (GeneralUtility::inList($row_categories, $pKey) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($pVal) . '<br />'; } $out_check .= '<br /><br /><input type="checkbox" name="indata[html]" value="1"' . ($row['module_sys_dmail_html'] ? ' checked="checked"' : '') . ' /> '; $out_check .= $GLOBALS["LANG"]->getLL('subscriber_profile_htmlemail') . '<br />'; $out .= $out_check; $out .= '<input type="hidden" name="table" value="' . $table . '" /><input type="hidden" name="uid" value="' . $uid . '" /><input type="hidden" name="CMD" value="' . $this->CMD . '" /><br /><input type="submit" name="submit" value="' . htmlspecialchars($GLOBALS["LANG"]->getLL('subscriber_profile_update')) . '" />'; $theOutput .= $this->doc->spacer(20); $theOutput .= $this->doc->section($GLOBALS["LANG"]->getLL('subscriber_profile'), $GLOBALS["LANG"]->getLL('subscriber_profile_instructions') . '<br /><br />' . $out); } return $theOutput; }