Wednesday, 22 April 2015

To setup up lastest CiviCRM on Joomla 3 plus version

If you are trying to install the latest CiviCRM on Joomla 3+, sometime you may stuck whilst installing the CRM component. In such instance, please add the below code on project .htaccess file and try to install again.

php_value upload_max_filesize 20M
php_value post_max_size 256M
php_value max_input_time 200

php_value memory_limit 128M
php_value register_globals off
php_value max_execution_time 600

Hope that helps! :-)

Tuesday, 21 April 2015

Error Handling on Joomla 3+

On latest version of Joomla (version 3+), the JError class has been depreciated and force to use the default PHP Exception which can be used as below:

/**
 * Function to verify the user access permission.
 * @return bool Return 'TRUE' if user has access, else throw an error.
 * @throws Exception
 */
protected function hasAccessPermission()
{    
 // Fetch the any user session.
 $user = JFactory::getUser(); 
 
 try {        
  /* if not logged in, prompt error. */
  if (!$user->get('guest')) 
  {
   /* Write your code here.. */
            return true;
  } 
  else {
   throw new Exception("You don't have permission to access this page. Please click here to Login for access.");
  }
 } 
 // Catch any exception
 catch (Exception $e) {
  // Display the message and exit;
  jexit($e->getMessage());
 }
}


Friday, 20 March 2015

Calling Custom Field Filter function outside of a form in Joomla 3+

This can be bit daunting to call the Custom Field function outside of a form.
Please refere here to find how to Create a Custom Field function in Joomla.

//Get GenreTypes from Custom Field Class
JFormHelper::addFieldPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/fields');
// works only if you set your field getOptions on public!!
$genre_types = JFormHelper::loadFieldType('myComponentGenreTypes', false);
$genre_types = $genre_types->getOptions()

The above method may not work sometimes, to resolve it, I have called a new helper function which pulled the same list (however we will have a function duplication which is not really ideal).
The help can be called as below but make sure that you have include the helper class path prior to call.

To include the helper class, add the below code on your com_mycomponent/mycomponent.php file.
// require helper files
JLoader::register('MyComponentHelper', dirname(__FILE__) . DS . 'helpers' . DS . 'mycomponent.php');

Then, call the helper function as following:
$genre_types = MyComponentHelper::getGenreTypes();

MySQL Upper Case, Lower Case, First Word Capital (similar to UCFirst())

The UCASE() Function 

The UCASE() function converts the value of a field to uppercase. 

MySQL UCASE() Syntax
SELECT UCASE(column_name) FROM table_name;
Syntax for SQL Server 
SELECT UPPER(column_name) FROM table_name;

The LCASE() Function

The LCASE() function converts the value of a field to lowercase.

MySQL LCASE() Syntax 
SELECT LCASE(column_name) FROM table_name;
Syntax for SQL Server 
SELECT LOWER(column_name) FROM table_name;

The First Letter Capital sntax (UCFirst() alternative):

The below script converts the selected column field value to First Letter Capital with rest to lower case.
MySQL Syntax 
SELECT CONCAT(LCASE(SUBSTRING(a_column_name, 1, 1)), 
LCASE(SUBSTRING(a_column_name, 2))) as a_column_name FROM table_name;
Syntax for SQL Server 
SELECT CONCAT(LCASE(SUBSTRING(a_column_name, 1, 1)), 
LCASE(SUBSTRING(a_column_name, 2))) as a_column_name FROM table_name;

Friday, 6 March 2015

Integration of Global IRIS (HSBC) payment


Integration the Global IRIS (HSBC) payment system into your website can be kinda daunting, however following below steps may make your life easier.

In fact, I have recently went through the process and thought would be helpful if you looking to work on it as well.

1. First of ally, please ask to Global IRIS (GI) technical team to configure the Sandbox account and live account into their system with below detail. You can contact them via direct number +44 845 702 3344 (Option 6)* or email;

Developer documention can be found here, pdf here.., I have found the documentation is bit outdated, but please contact & confirm with them if necessary.

In fact, you have to ask them to provide below details (including login info) for both environment (sandbox and live) :
Modes Live Test
Action URL https://hpp.globaliris.com/pay https://hpp.sandbox.globaliris.com/pay
Merchant ID - -
Secret hash string: - secret
Account: internet internet
Below is the login detail to for HSBC reporting system
Reportin URL: https://reporting.globaliris.com/login https://reporting.sandbox.globaliris.com
Username: - -
Password: - -

Then, use create the request form page, response page and confirmation page.
For more detail, please refere here including documentation and codes @GitHub

Wednesday, 28 January 2015

Calling model functions from another classes or views files in Joomla 3+

In Joomla 3+ version, to initialise any model and to call them from another model or helper or view class/files, please follow instruction;

For example, you have a sample model class (as shown below) which exists on
root/components/com_mycomponent/models/gallery.php
or
root/administrator/components/com_mycomponent/models/gallery.php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import the Joomla modellist library
jimport('joomla.application.component.modellist');

/**
 * Gallery Model
 */
class MycomponentModelGallery extends JModelList
{
 /**
  * Method to fetch all list of published galleries
  *
  * @return      string  An SQL query
  */
 protected function getGalleryList()
 {
  ..............
  ..............
  
  return $items;
 }

Now, please use the below format initialising the gallery model and call the functions:
// Use JPATH_ADMINISTRATOR instead of JPATH_SITE to call administrator model classes;
// Include the file path;
JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_mycomponent/models', 'MycomponentModel'); 
// Initialising the included class;
$gallery_model = JModelLegacy::getInstance('Gallery', 'MycomponentModel');
$galleries = $gallery_model->getGalleryList();

Friday, 2 January 2015

Options to run multi-versions PHP within on WHM Cpanel

If you are looking for solution to run multi-version of PHP by domain in WHM Cpanel, I have found people using tools called ntPHPSelector.

WHM Cpanel doesn't have such native feature, however, I have found their team were keen to build an extension for it in future. Hopefully, it will be available soon, fingures cross!! find more here..

Currently, there are few WHM providers which does support Multiple PHP Versions as below:
  • Virtualmin since 3.99 can do that
  • PLesk since 11.5 can do that
  • Direct Admin can do that
  • cPanel cannot do that unless you move to CloudLinux paying an additional license


Now, let jump to the wayout for now;

1. First check whether the suPHP Handler is enabled or not by going to WHM > Configure PHP and suEXEC
PHP 5 Handler => suphp

If not active, run the below command
/usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1


2. Run the following commond once you logged in as root into the server (Via SSH or you can use puTTY), which may take few mintues so wait until instillation completes.
cd /usr/local/src
wget -N http://nixtree.com/download/free/ntphpselector_manage.sh
sh ntphpselector_manage.sh install

3. Go to the domain Cpanel and find the ntPHPSelector under the Software and Services to run the different version of PHP.


If you find anything, please keep on post...