Commit d6d34169 authored by Keval Pandya's avatar Keval Pandya

[Task] Introduce community membership for new registrations Implementation done

parent e8c55ec1
Pipeline #6670 failed with stages
in 17 seconds
<?php
declare(strict_types = 1);
namespace T3o\T3omy\Controller;
use T3o\T3omy\Domain\Model\MyProfile;
use T3o\T3omy\Domain\Repository\CommunityMembershipRepository;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
/**
* CommunityMembershipController
*/
class CommunityMembershipController extends ActionController
{
/**
* @var CommunityMembershipRepository
*/
public $communityMembershipRepository;
/**
* @var persistenceManager
*/
public $persistenceManager;
/**
* @param CommunityMembershipRepository $communityMembershipRepository
*/
public function injectUserProfileRepository(CommunityMembershipRepository $communityMembershipRepository)
{
$this->communityMembershipRepository = $communityMembershipRepository;
}
/**
* @param PersistenceManager $persistenceManager
*/
public function injectPersistenceManager(PersistenceManager $persistenceManager)
{
$this->persistenceManager = $persistenceManager;
}
/**
* action update
*
* @param \T3o\T3omy\Domain\Model\CommunityMembership $user
* @return void
*/
public function updateAction(\T3o\T3omy\Domain\Model\CommunityMembership $user)
{
$decide = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('decide');
if($user == 1){
if($decide){
$user->setCommunityMembership(1);
$user->setCommunityMembershipInformStatus(1);
$this->communityMembershipRepository->update($user);
$this->redirectToUri($this->settings['location']);
}else{
$user->setCommunityMembershipInformStatus(1);
$this->communityMembershipRepository->update($user);
$uri = $this->uriBuilder->reset()
->setTargetPageUid($GLOBALS['TSFE']->id)
->setCreateAbsoluteUri(true)
->build();
$this->redirectToUri($uri);
}
}
}
/**
* action determineMembership
*
* @return void
*/
public function determineMembershipAction(){
if(isset($GLOBALS['TSFE']->fe_user->user['uid'])){
$user = $this->communityMembershipRepository->findCommunityMembershipStatus(
$GLOBALS['TSFE']->fe_user->user['uid']
);
if(isset($user[0])){
$this->view->assign('communityMembershipStatus', true);
$this->view->assign('user', $user[0]);
}else{
$this->view->assign('communityMembershipStatus', false);
}
}
}
}
<?php
namespace T3o\T3omy\Domain\Model;
/***
*
* This file is part of the "t3omy" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2019
*
***/
/**
* CommunityMembership
*/
class CommunityMembership extends \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
{
/**
* communityMembership
*
* @var bool
*/
protected $communityMembership = false;
/**
* communityMembershipInformStatus
*
* @var bool
*/
protected $communityMembershipInformStatus = false;
/**
* Returns the communityMembership
*
* @return bool $communityMembership
*/
public function getCommunityMembership()
{
return $this->communityMembership;
}
/**
* Sets the communityMembership
*
* @param bool $communityMembership
* @return void
*/
public function setCommunityMembership($communityMembership)
{
$this->communityMembership = $communityMembership;
}
/**
* Returns the boolean state of communityMembership
*
* @return bool
*/
public function isCommunityMembership()
{
return $this->communityMembership;
}
/**
* Returns the communityMembershipInformStatus
*
* @return bool $communityMembershipInformStatus
*/
public function getCommunityMembershipInformStatus()
{
return $this->communityMembershipInformStatus;
}
/**
* Sets the communityMembershipInformStatus
*
* @param bool $communityMembershipInformStatus
* @return void
*/
public function setCommunityMembershipInformStatus($communityMembershipInformStatus)
{
$this->communityMembershipInformStatus = $communityMembershipInformStatus;
}
/**
* Returns the boolean state of communityMembershipInformStatus
*
* @return bool
*/
public function isCommunityMembershipInformStatus()
{
return $this->communityMembershipInformStatus;
}
}
<?php
declare(strict_types=1);
namespace T3o\T3omy\Domain\Repository;
use TYPO3\CMS\Extbase\Persistence\Repository;
/**
* Class CommunityMembershipRepository
*
* @method findByUid(int $uid)
*/
class CommunityMembershipRepository extends Repository
{
/**
* @param int $uid
* @return \T3o\T3omy\Domain\Model\CommunityMembership|object
*/
public function findCommunityMembershipStatus(int $uid)
{
$query = $this->createQuery();
$query->getQuerySettings()
->setRespectStoragePage(false);
return $query->matching(
$query->logicalAnd(
$query->equals('uid', $uid),
$query->equals('community_membership_inform_status', 0)
)
)->execute();
}
}
......@@ -71,3 +71,62 @@ $passwordHashFields = 'hash_md5, hash_sha1, hash_crypt';
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('fe_users', $feUsersColumns);
/*--------------------------------- Community Membership -------------------------------------------*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'fe_users',
$GLOBALS['TCA']['fe_users']['ctrl']['type'],
'',
'after:' . $GLOBALS['TCA']['fe_users']['ctrl']['label']
);
$tmp_t3omy_columns = [
'community_membership' => [
'exclude' => true,
'label' => 'LLL:EXT:t3omy/Resources/Private/Language/locallang_db.xlf:tx_t3omy_domain_model_communitymembership.community_membership',
'config' => [
'type' => 'check',
'items' => [
'1' => [
'0' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.enabled'
]
],
'default' => 0,
]
],
'community_membership_inform_status' => [
'exclude' => true,
'label' => 'LLL:EXT:t3omy/Resources/Private/Language/locallang_db.xlf:tx_t3omy_domain_model_communitymembership.community_membership_inform_status',
'config' => [
'type' => 'check',
'items' => [
'1' => [
'0' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.enabled'
]
],
'readOnly' => 1,
'default' => 0,
]
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('fe_users', $tmp_t3omy_columns);
/* inherit and extend the show items from the parent class */
if (isset($GLOBALS['TCA']['fe_users']['types']['0']['showitem'])) {
$GLOBALS['TCA']['fe_users']['types']['Tx_Extbase_Domain_Model_FrontendUser']['showitem'] = $GLOBALS['TCA']['fe_users']['types']['0']['showitem'];
} elseif (is_array($GLOBALS['TCA']['fe_users']['types'])) {
// use first entry in types array
$fe_users_type_definition = reset($GLOBALS['TCA']['fe_users']['types']);
$GLOBALS['TCA']['fe_users']['types']['Tx_Extbase_Domain_Model_FrontendUser']['showitem'] = $fe_users_type_definition['showitem'];
} else {
$GLOBALS['TCA']['fe_users']['types']['Tx_Extbase_Domain_Model_FrontendUser']['showitem'] = '';
}
$GLOBALS['TCA']['fe_users']['types']['Tx_Extbase_Domain_Model_FrontendUser']['showitem'] .= ',--div--;LLL:EXT:t3omy/Resources/Private/Language/locallang_db.xlf:tx_t3omy_domain_model_communitymembership,';
$GLOBALS['TCA']['fe_users']['types']['Tx_Extbase_Domain_Model_FrontendUser']['showitem'] .= 'community_membership, community_membership_inform_status';
......@@ -20,7 +20,45 @@ plugin.tx_t3omy {
}
ipapi.access_key = {$tx_t3omy.ipapi.access_key}
}
plugin.tx_t3omy_communitymembership {
view {
templateRootPaths.0 = EXT:t3omy/Resources/Private/Templates/
partialRootPaths.0 = EXT:t3omy/Resources/Private/Partials/
layoutRootPaths.0 = EXT:t3omy/Resources/Private/Layouts/
}
features {
#skipDefaultArguments = 1
# if set to 1, the enable fields are ignored in BE context
ignoreAllEnableFieldsInBe = 0
# Should be on by default, but can be disabled if all action in the plugin are uncached
requireCHashArgumentForActionArguments = 1
}
settings{
location = https://typo3.org/project/association/membership/
}
mvc {
callDefaultActionIfActionCantBeResolved = 1
}
}
lib.communityMembershipPopup = USER_INT
lib.communityMembershipPopup{
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = Communitymembership
extensionName = T3omy
controller = CommunityMembership
vendorName = T3o
action = determineMembership
switchableControllerActions {
CommunityMembership {
1 = determineMembership
2 = update
}
}
settings =< plugin.tx_t3omy_communitymembership.settings
view =< plugin.tx_t3omy_communitymembership.view
features =< plugin.tx_t3omy_communitymembership.features
}
config.tx_realurl_enable = 1
[applicationContext = Production/Live]
......
......@@ -48,6 +48,21 @@
<trans-unit id="tx_userprofile.about_me">
<source>About me</source>
</trans-unit>
<trans-unit id="tx_t3omy_domain_model_communitymembership">
<source>Community Membership</source>
</trans-unit>
<trans-unit id="tx_t3omy_domain_model_communitymembership.community_membership">
<source>TYPO3 Community Membership</source>
</trans-unit>
<trans-unit id="tx_t3omy_domain_model_communitymembership.community_membership_details">
<source>Are you intrested to get community member of the TYPO3 Association?</source>
</trans-unit>
<trans-unit id="tx_t3omy_domain_model_communitymembership.btn_yes">
<source>Yes</source>
</trans-unit>
<trans-unit id="tx_t3omy_domain_model_communitymembership.btn_no">
<source>No</source>
</trans-unit>
</body>
</file>
</xliff>
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2019-03-30T11:29:06Z" product-name="t3omy">
<header/>
<body>
<trans-unit id="tx_t3omy_domain_model_communitymembership">
<source>Community Membership</source>
</trans-unit>
<trans-unit id="tx_t3omy_domain_model_communitymembership.community_membership">
<source>Community Membership</source>
</trans-unit>
<trans-unit id="tx_t3omy_domain_model_communitymembership.community_membership_inform_status">
<source>Show the Notification Status</source>
</trans-unit>
<trans-unit id="fe_users.tx_extbase_type.Tx_T3omy_CommunityMembership">
<source>t3omy CommunityMembership</source>
</trans-unit>
<trans-unit id="tx_t3omy_communitymembership.name">
<source>Community Membership</source>
</trans-unit>
<trans-unit id="tx_t3omy_communitymembership.description">
<source></source>
</trans-unit>
</body>
</file>
</xliff>
\ No newline at end of file
<html xmlns:f="https://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<div class="tx-t3omy">
<f:render section="content" />
</div>
</html>
\ No newline at end of file
<html xmlns:f="https://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Default"/>
This template displays a EDIT form for the current domain object.
If you modify this template, do not forget to change the overwrite settings
in /Configuration/ExtensionBuilder/settings.yaml:
Resources:
Private:
Templates:
Edit.html: keep
Otherwise your changes will be overwritten the next time you save the extension in the extension builder
<f:section name="content">
<f:if condition="{communityMembershipStatus}">
<div class="modal fade membershipModal" id="membershipModal" tabindex="-1" role="dialog"
aria-labelledby="membershipModal" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times; </span>
</button>
<h4>
<f:translate key="tx_t3omy_domain_model_communitymembership.community_membership"/>
</h4>
</div>
<div class="modal-body">
<p>
<f:translate key="tx_t3omy_domain_model_communitymembership.community_membership_details"/>
</p>
<form>
<div class="membership-block">
<f:link.action id="decide-yes" action="update" controller="CommunityMembership"
arguments="{user: user}" class="btn btn-primary close-modal-btn"
additionalParams="{decide: 1}">
<f:translate key="tx_t3omy_domain_model_communitymembership.btn_yes"/>
</f:link.action>
<f:link.action id="decide-no" action="update" controller="CommunityMembership"
arguments="{user: user}" class="btn btn-primary close-modal-btn"
additionalParams="{decide: 0}">
<f:translate key="tx_t3omy_domain_model_communitymembership.btn_no"/>
</f:link.action>
</div>
</form>
</div>
</div>
</div>
</div>
</f:if>
</f:section>
</html>
\ No newline at end of file
......@@ -69,3 +69,21 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['password_changed'][] = \T3o\T
// Hook to process reactivate process via BE
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'][] = \T3o\T3omy\Hooks\ReactivateUserHook::class;
call_user_func(
function()
{
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'T3o.T3omy',
'Communitymembership',
[
'CommunityMembership' => 'determineMembership, update'
],
// non-cacheable actions
[
'CommunityMembership' => 'determineMembership, update'
]
);
}
);
......@@ -6,6 +6,8 @@ CREATE TABLE fe_users (
twitter VARCHAR (255),
facebook VARCHAR (255),
terms_version VARCHAR (255),
community_membership smallint(5) unsigned DEFAULT '0' NOT NULL,
community_membership_inform_status smallint(5) unsigned DEFAULT '0' NOT NULL,
hash_md5 VARCHAR(255) DEFAULT '' NOT NULL,
hash_sha1 VARCHAR(255) DEFAULT '' NOT NULL,
......
......@@ -27,6 +27,18 @@ config.tx_extbase {
tableName = old_users
}
}
In2code\Femanager\Domain\Model\User {
subclasses {
Tx_Extbase_Domain_Model_FrontendUser = T3o\T3omy\Domain\Model\CommunityMembership
}
}
T3o\T3omy\Domain\Model\CommunityMembership {
mapping {
tableName = fe_users
recordType = Tx_Extbase_Domain_Model_FrontendUser
}
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment