Calcetines Extreme

Calcetines Extreme
Take care of you using the best socks

Friday, September 21, 2012

Installing Magento without Mcrypt


problem
Can't install magento as mcrypt is not enabled on php server, that happend on most of shared hosting

Solution:

Step One: edit /app/code/core/Mage/Install/Installer/Env.php, and find

                Mage::getSingleton('install/session')->addError(
                    Mage::helper('install')->__('PHP Extension "%s" must be loaded', $extension)
                );
just above it, add

                if ($extension == 'mcrypt') {
                    return true;   
                }
Step Two: create /lib/Varien/Crypt/Base64.php and throw this into it

<?php

class Varien_Crypt_Base64 extends Varien_Crypt_Abstract {
    public function __construct(array $data=array()) {
        parent::__construct($data);
    }

    public function init($key) {
         return $this;
    }

    public function encrypt($data) {
        if (!strlen($data)) {
            return $data;
        }
        
        return base64_encode($data);
    }
    
    public function decrypt($data) {
        if (!strlen($data)) {
            return $data;
        } 

        return  base64_decode($data);
    }
}
Last Step: edit /lib/Varien/Crypt.php and change

    static public function factory($method='mcrypt')

with

    static public function factory($method='base64')

just done.

Saturday, September 15, 2012

Update K2 to send mail notifications on new comments

Problem:

Really it's not a problem, is a new requirement to allow Joomla K2 component to send notifications when a new comment has been published on frontpage; i still don't understand how that functionality has not been implementd on standar release of K2.

Solution:

we need to edit the code that allow to save new comments, you can find that on components/com_k2/models/item.php once.

1.- edit item.php and search for function comment()

2.- search string "...K2_COMMENT_ADDED_AND_WAITING_FOR_APPROVAL..."

3.- before that line add the next code:


$mainframe = &JFactory::getApplication(); $mail = &JFactory::getMailer(); $senderEmail = $mainframe->getCfg('mailfrom'); $senderName = $mainframe->getCfg('fromname'); $mail->setSender(array($senderEmail, $senderName)); $mail->setSubject(JText::_('K2_COMMENT_REPORT')); $mail->IsHTML(true); $body = " <strong>".JText::_('K2_NAME')."</strong>: ".$name." <br/> <strong>".JText::_('K2_REPORT_REASON')."</strong>: ".$reportReason." <br/> <strong>".JText::_('K2_COMMENT')."</strong>: ".nl2br($row->commentText)." <br/> "; $mail->setBody($body); $mail->ClearAddresses(); $mail->AddAddress($params->get('commentsReportRecipient', $mainframe->getCfg('mailfrom'))); $mail->Send();