+appThe files: Grid.php
+code
+community
+KalidadBusinessSolutions
+CustomerExpiration
+Block
+Customer
+Grid.php
+Widget
+Grid
+Column
+Renderer
+Datetime.php
+controllers
+AdminController.php
+etc
+config.xml
+system.xml
+Helper
+Data.php
+Model
+Observer.php
+sql
+customerexpiration_setup
+mysql4-install-0.0.1.php
+etc
+modules
+KalidadBusinessSolutions_All.xml
+locale
+en_US
+KalidadBusinessSolutions_CustomerActivation.csv
class KalidadBusinessSolutions_CustomerExpiration_Block_Adminhtml_Customer_Grid extends Mage_Adminhtml_Block_Customer_GridDatetime.php
{
public function setCollection($collection)
{
if ($this->_isActive())
{
$collection->addAttributeToSelect('customer_expirydate');
}
return parent::setCollection($collection);
}
public function addColumn($name, $params)
{
if ($this->_isActive())
{
if ($name == 'action')
{
self::addColumn('customer_expirydate', array(
'header' => Mage::helper('customer')->__('Customer Activated'),
'align' => 'center',
'type' => 'datetime',
'default' => '0',
'index' => 'customer_expirydate',
'renderer' => 'customerexpiration/adminhtml_widget_grid_column_renderer_datetime'
));
}
}
return parent::addColumn($name, $params);
}
protected function _isActive()
{
if(Mage::getStoreConfig('customer/customerexpiration/disable_ext') &&
!Mage::getStoreConfig('customer/customerexpiration/always_active_in_admin'))
{
return false;
}
return true;
}
}
class KalidadBusinessSolutions_CustomerExpiration_Block_Adminhtml_Widget_Grid_Column_Renderer_DatetimeAdminController.php
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Datetime
{
public function render(Varien_Object $row)
{
if ($data = $this->_getValue($row)) {
$format = $this->_getFormat();
try {
$data = Mage::app()->getLocale()->date($data, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
}
catch (Exception $e)
{
$data = Mage::app()->getLocale()->date($data, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
}
return $data;
}
return $this->getColumn()->getDefault();
}
}
class KalidadBusinessSolutions_CustomerExpiration_AdminController extends Mage_Adminhtml_Controller_ActionData.php
{
}
class KalidadBusinessSolutions_CustomerExpiration_Helper_Data extends Mage_Core_Helper_AbstractObserver.php
{
}
class KalidadBusinessSolutions_CustomerExpiration_Model_Observer extends Mage_Core_Model_Abstractmysql4-install-0.0.1.php
{
const XML_PATH_MODULE_DISABLED = 'customer/customerexpiration/disable_ext';
/**
* Fired on customer_login event
* Check if the customer has been activated (via adminhtml)
* If not, through login error
*
* @param Varien_Event_Observer $observer
*/
public function customerLogin($observer)
{
if (Mage::getStoreConfig(self::XML_PATH_MODULE_DISABLED) == 1)
{
return;
}
if ($this->_isApiRequest())
{
return;
}
$customer = $observer->getEvent()->getCustomer();
$session = Mage::getSingleton('customer/session');
$todays_date = date("Y-m-d");
$today = strtotime($todays_date);
if ($today >= strtotime($customer->getData('customer_expirydate')))
{
$session->setCustomer(Mage::getModel('customer/customer'))->setId(null);
Mage::throwException(Mage::helper('customerexpiration')->__('This account is not activated or is expired.'));
}
}
/**
* Return true if the request is made via the api.
*
* @return boolean
*/
protected function _isApiRequest()
{
return Mage::app()->getRequest()->getModuleName() === 'api';
}
}
$this->startSetup();config.xml
$this->addAttribute('customer', 'customer_expirydate', array(
'type' => 'datetime',
'input' => 'date',
'label' => 'Active Until',
'global' => 1,
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'default' => null,
'visible_on_front' => 0,
));
$customer = Mage::getModel('customer/customer');
$attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId();
$this->addAttributeToSet('customer', $attrSetId, 'General', 'customer_expirydate');
if (version_compare(Mage::getVersion(), '1.4.2', '>='))
{
Mage::getSingleton('eav/config')
->getAttribute('customer', 'customer_expirydate')
->setData('used_in_forms', array('adminhtml_customer'))
->save();
}
$this->endSetup();
<config>system.xml
<modules>
<KalidadBusinessSolutions_CustomerExpiration>
<version>0.0.1</version>
</KalidadBusinessSolutions_CustomerExpiration>
</modules>
<global>
<models>
<customerexpiration>
<class>KalidadBusinessSolutions_CustomerExpiration_Model</class>
</customerexpiration>
</models>
<helpers>
<customerexpiration>
<class>KalidadBusinessSolutions_CustomerExpiration_Helper</class>
</customerexpiration>
</helpers>
<blocks>
<customerexpiration>
<class>KalidadBusinessSolutions_CustomerExpiration_Block</class>
</customerexpiration>
<adminhtml>
<rewrite>
<!-- overwrite Mage_Adminhtml_Block_Customer_Grid to add activation to grid -->
<customer_grid>KalidadBusinessSolutions_CustomerExpiration_Block_Adminhtml_Customer_Grid</customer_grid>
</rewrite>
</adminhtml>
</blocks>
<resources>
<customerexpiration_setup>
<setup>
<module>KalidadBusinessSolutions_CustomerExpiration</module>
<class>Mage_Customer_Model_Entity_Setup</class>
</setup>
</customerexpiration_setup>
</resources>
</global>
<admin>
<routers>
<customerexpiration>
<use>admin</use>
<args>
<module>KalidadBusinessSolutions_CustomerExpiration</module>
<frontName>customerexpiration</frontName>
</args>
</customerexpiration>
</routers>
</admin>
<frontend>
<events>
<customer_login>
<observers>
<customerexpiration>
<type>singleton</type>
<class>customerexpiration/observer</class>
<method>customerLogin</method>
</customerexpiration>
</observers>
</customer_login>
</events>
<translate>
<modules>
<KalidadBusinessSolutions_CustomerExpiration>
<files>
<default>KalidadBusinessSolutions_CustomerExpiration.csv</default>
</files>
</KalidadBusinessSolutions_CustomerExpiration>
</modules>
</translate>
</frontend>
<default>
<customer>
<CustomerExpiration>
<disable_ext>0</disable_ext>
<always_active_in_admin>1</always_active_in_admin>
</CustomerExpiration>
</customer>
</default>
<adminhtml>
<translate>
<modules>
<KalidadBusinessSolutions_CustomerExpiration>
<files>
<default>KalidadBusinessSolutions_CustomerExpiration.csv</default>
</files>
</KalidadBusinessSolutions_CustomerExpiration>
</modules>
</translate>
</adminhtml>
</config>
<?xml version="1.0"?>KalidadBusinessSolutions_All.xml
<config>
<sections>
<customer translate="label" module="customer">
<groups>
<customerexpiration translate="label" module="customerexpiration">
<label>Customer Expiration</label>
<sort_order>768</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<disable_ext translate="label" module="customerexpiration">
<label>Disable Customer Expiration</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</disable_ext>
<always_active_in_admin translate="label" module="customerexpiration">
<label>Always enable in admin interface</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>11</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<comment>If you want to set account expiry via the admin interface</comment>
</always_active_in_admin>
</fields>
</customerexpiration>
</groups>
</customer>
</sections>
</config>
KalidadBusinessSolutions_CustomerActivation.csv
true
community
"This account is not activated or is expired.","This account is not activated or is expired."After installing all the mentioned files you showed have he ff view: System View
"Active until","Active until"