Monday, May 13, 2013

Creating custom view for SugarCRM

Hi,
From last few days, i was active on SugarCRM product and searching for the customizing its properties.
I found out how to customize the view layer.

Step 1: Create Custom module in customer dir
i.e. custom/modules//controller.php

controller.php file responsible for the redirection of view file.

ex:


class your-module-nameController extends SugarController {

    public function action_test() {
        $this->view = "welcome";  //call for the view file in views dir
    }
}


Step 2: create views dir i.e. custom/modules//views/view.welcome.php

code:

class your-module-nameViewWelcome extends SugarView {
     function
your-module-nameViewWelcome(){
         parent::SugarView();
     }


    public function preDisplay(){
        $this->dv->tpl = 'custom/modules//tpl/welcome.tpl';
    }


    function display(){
         $smarty = new Sugar_Smarty();
         parent::display();
         $smarty->assign("welcome", 'welcome');
         $smarty->display($this->dv->tpl);
    }
}

Step 3: create tpl file inside custom/modules//tpl/welcome.tpl

{ $welcome } To TPL Page


your will access the page via:

http:///module=&action=test

then you will see your template.

I hope this information would help you :)





Tuesday, November 1, 2011

MySql View DEFINER and SQL Security

Hi,

Some time back, I tried to backup a database from my server and restored it on my localhost mysql server. It had a few views. On taking backup from server i always getting issue i.e. :

mysqldump: Got error: 1449: The user specified as a definer ('msilink'@'localhost') does not exist when using LOCK TABLES

So I opened the dump file and found that the error was being caused by a line which looks like this :

/*!50013 DEFINER=`msilink`@`localhost` SQL SECURITY DEFINER */

This line appeared in every view definition. So the simple reason was that msilink@localhost, user which had created the view (on the server) and when importing the database on local system there was no user named ‘projects’ in MySql.

For that i just open the file and update the line: "50013 DEFINER=`msilink`@`localhost`" with "50013 DEFINER=`root`@`localhost`"

with the following command(In Linux VI Editor):

:%s/50013 DEFINER=`msilink`@`localhost`/50013 DEFINER=`root`@`localhost`/g


then save and close the file. The above solutions worked for me.

Solution is to create a view with SQL security invoker like this :

CREATE
SQL SECURITY INVOKER
VIEW system_users AS SELECT host,user,password FROM mysql.user;

The above statement allows this view to be viewed by any user who invokes the view.
By default the SQL SECURITY is DEFINER which means the definer user can only view it.


:: Alternative Solution ::
Create another user that have all the privileges like as root, viw the following query:

mysql > grant all PRIVILEGES on *.* to msilink@localhost IDENTIFIED BY 'root' WITH GRANT OPTION;

In General:
mysql > grant on to @localhost IDENTIFIED BY '' WITH GRANT OPTION;

That also solve your problem.

Monday, July 18, 2011

CodeIgniter - Routing

Hi,

Implementation of the routing is the interesting idea to manage short URL re-writing.

Way to implement the routing :
Just open the application/config/routes.php, insert the line at the end of the file.

1) if you want that URL would be http://example.com/work/holiday
here, work is the controller name and holiday is the data that would be dynamically changed. So, to implement this just write like this:
$route['work/(:any)'] = 'work/work_detail/$1';
here (:any) = would accept any type of argument,
work/work_detail : class/function relationship
$1 : argument passed

class Implementation:

class Work extends CI_Controller{

function __construct(){
parent::__construct();
}
function work_detail($arg){
echo $arg; //would return holiday
}

2) If your URL is http://example.com/sevice/data, where service is controller and data would dynamic changed,
but client requirement is URL : http://example.com/data only. then you have to manager class/function relationship implicitly.

open routes.php and insert line at the end of the file.
$route['^(?!work|home).*'] = 'page/info/$1';

here, i used regular expression to bypass control from work,home class, means url : example.com/work and example.com/home not there then it would follow page class.

i.e. if URL : http://example.com/data called then specific routing will transfer control to the page/info :: class/function relationship,

it will help in short URL re-writing cases.
Implementation:
Class Page extends CI_Controller{
function __construct(){
parent::__construct();
}

function info($arg){
echo $arg; //would give data
}
}


Bye everybody...

CodeIgniter - an open source Web Application Framework

Hi Everybody,

From last 3 month, i was working on codeIgniter Framework. And i found its very interesting tool to manage MVC structure.

I start my work on version 2.0.2, it's the latest version of CI. Here many new feature introduced like :
# Support for PHP 4 is gone, PHP 5.1 is now a requirement.
# CSRF Protection built into the form helper
# Drivers
# Application Packages
# Scaffolding, having been deprecated for a number of versions, has been removed.
# Removed the deprecated Validation Class.
# Plugins have been removed, in favor of Helpers.
# Added routing overrides to the main index.php file, enabling the normal routing to be overridden on a per “index” file basis.
# Added $route[‘404_override’] to allow 404 pages to be handled by controllers.

which are not available in CI older version i.e. 1.7.x versions.

CI has very good User Guide that provide methods of creating web application with best implementation way.
URL of User-Guid: http://codeigniter.com/user_guide/

At the end i like it so much because of its light weight, good user guid and good support on bug fixing.

Bye :)

Monday, November 22, 2010

Symfony : Radio Widgets with formatting

Hi,
symfony provides concept of widget. it's just like a sub-framework that provide classes to output HTML fields like input, textarea, select, radio etc...

Suppose you want to create widgets for the set of radio buttons with the option of html formatting of the radio button. creating a form class in module lib directory say Itinerary.Form.class.php
// Itinerary.Form.class.php
class ItineraryForm extends sfForm
{

  public static function radioFormatter($widgets, $inputs)
  {
    $rows = array();
    foreach ($inputs as $input)
    {
      $rows[] = $input['input'].$input['label'];
    }
    return "".implode("", $rows)."";
  }

  public function configure()
  {
      $tourTipChoice    =    array(
                                                         'tourItinerary'                => 'Itinerary',
                                                         'InclusionsExclusions'=> 'Inclusions/ Exclusions',
                                                         'sightSeeing'                 => 'Sightseeing'
                             );

    $this->setWidgets(array( 'tourTip'   => new sfWidgetFormSelectRadio(array(
'choices'                => $tourTipChoice,
                                                                              'formatter'            => array($this, 'radioFormatter')
                                                                             ))
                      ));

    $this->validatorSchema->setOption('allow_extra_fields', true);      
    $this->validatorSchema->setOption('filter_extra_fields', false);
    $this->setDefault('tourTip', 'Itinerary');
  }
}



after that just creating the object this class in action.class.php.
suppose you want to render the widget in your index file. so just create object inside the index funciton like as :
public function executeIndex(sfWebRequest $request)
  {
      $this->form = new ItineraryTourForm();  //Used to call form widgets
  }

now you have to call only the function inside template i.e. in indexSuccess.php

echo $form['tourTip']->render();

It will render the  radio button list in the vertical format as we set in formatter. If we want to add other event on the radio button like onclick(), onsubmit() etc... i.e.

echo $form['tourTip']->render( array('onclick'=> 'showtourTip(this.value);'));

Wednesday, June 23, 2010

Symfony Propel-Database Backup

In symfony, we can take backup of our database with the help symfony commands i.e.

>> To Take dump of your DB
# symfony propel-dump-data application-name file.yml
EX:
# symfony propel-dump-data frontend dump.yml

it will create dump.yml file in data/fixtures/dump.yml.

>> To Reuse of your dump data into your DB
# symfony propel:data-load application-name
EX:
# symfony propel:data-load frontend

It will re-create your db structure......

Friday, June 4, 2010

ProcessMaker -- Open Source Business Process Management

Hi,

From Last few days i was working on processmaker, that is use to design business process for mid sized or SME organization.

it take 3-4 days to config and know about what it is. when i start to configuration, i was just wondering with so many question...
what should i do to start it??, what it will give me??, in what area it will be useful???, is it so powerful tool??

After a long research, I found many solution and good point is that it's have online library/templates to learn new things/feature.

In online library, where you can just edit process and can use in your need...

By the way, I just found out some of the features there are following...

ProcessMaker makes it easy to optimize workflow management and business operations.
1. Create workflow maps, or choose from templates.
2. Design custom forms for all your organization's processes.
3. Pull data from other forms, databases and external sources through web services.
4. Track case progress to see where process delays occur.
5. Analyze results to improve efficiency and effectiveness.

ProcessMaker is a user-friendly workflow manangement system:
1. No programming experience necessary.
2. Easy-to-use AJAX interface for simple process creation and instant preview.
3. Drag-and-drop, browser-based interface makes it simple to map processes.
4. Add users, dynaforms, documents, messages, and alerts with the click of a button.
5. Optional HTML editor gives full control over form appearance.

ProcessMaker gives your organization the advantage of open source:
1. Lower implementation costs, higher value.
2. No vendor lock-in.
3. Installs on Linux & Windows (LAMP/WAMP).
4. Integrates with databases including MySql, Oracle, SQL, PostgreSql.
5. Connects with third party systems through web services.
6. Easy to share information with DMS, BI, CMS, ERP systems.


At the end, here you can assign user rights on particular task to view uploaded file,trigger of mail,view of generated doc/report etc...

Symfony with PostgreSql

PostgreSql connection with symfony is bit tuffer then mysql db.
For that, you have to edit some of the file in your application directory....
Step 1: Edit config/database.yml

Step 2: Edit file config/propel.ini
here set....
propel.database = pgsql
propel.database.creatUrl = pgsql://user:password@server-ip/database-name
propel.database.url = pgsql://user:password@server-ip/database-name
Step 3: Edit file apps/frontend/config/setting.yml
here set...
use_database: on
orm: propel
Step 4: symfony cc
After that build your model that create sql and respected table classes. via..
1. symfony propel: build-model //create classes
2. symfony propel:build-sql // cretae .sql file
3. symfony propel:insert-sql //create table structure

Wednesday, March 10, 2010

Symfony : Plugin Installation

To install plugin in Symfony
# symfony plugin:install sfGuardPlugin
Uninstalling the plugin is just remove of plugin from the project
# symfony plugin:uninstall sfGuardPlugin
To upgrade the plugin
# symfony plugin:upgrade sfGuardPlugin
To list the installed plugin
symfony plugin:list

Symfony Installation in Linux

To Install Symfony framework, required php-pear package. that help to install/un-install the symfony.
There are few steps to install it and run on CLI:
Step 1: yum install php-pear*
Step 2: pear install symfony/symfony
OR
Step 2: if you are specific to install symfony version
pear install symfony/symfony-1.1.9
check symfony version:
# symfony -V
TO Un-Install Symfony
pear uninstall symfony/symfony