PHP 5.2 and 5.3 Differences and Work-Arounds

Something I’ve been frustrated with as a developer is the subtle differences in PHP versions 5.2 and 5.3. One of our service providers hasn’t been able to upgrade to 5.3 yet, but all of my code that I write on my machine (using 5.3) has to run on their servers. While this isn’t often a problem, every now and then I find the subtle differences. PHP 5.3 actually has a lot of improvements over 5.2, here are a few of the differences I’ve found [the hard way] and the workarounds I use.

nl2br

The basic function for converting new-lines to HTML line breaks, nl2br in PHP 5.3 incorporates the ability to use (X)HTML-tailored tag ending (i.e. <br /> instead of <br>). But if you’re on 5.2 or under, the second parameter isn’t available and attempting to use it will result in errors.

if(version_compare(PHP_VERSION,'5.3.0') > 1){
  $html = nl2br($text,1);
} else {
  $html = nl2br($text);
}

DateTime Objects and Methods

PHP 5.3 has awesome new functionality for meddling with DateTime objects that just doesn’t exist in PHP 5.2. Just check out createFromFormat(), diff(), add() and sub().

Here’s a work-around I use in place of diff():

 // start with two DateTime objects
$datetime_one = new DateTime();
$datetime_two = new DateTime();

// the necessary way using PHP 5.2
$datetime_one_string = $datetime_one->format('U');
$datetime_two_string = $datetime_two->format('U');
// get a difference represented as an int, number of seconds
$difference = abs($datetime_one_string - $datetime_two_string);

// the fun way using PHP 5.3, returning a DateInterval obj
$difference = $datetime_one->diff($datetime_two);

The benefit of having $difference as a DateInterval object is that you can then modify and format however you want. The PHP 5.2 return above is simply an integer as a number of seconds, which can be converted in a few more steps, but is more cumbersome.

Posted in PHP | Leave a comment

SugarCRM System CleanUp

Spring is here, and maybe it’s time for your annual SugarCRM System Clean-up. Sugar’s database system is good, but don’t things just feel better when there isn’t ten-year-old data lurking around? Here are some scripts I use when I’m pruning a database to drop off deleted data or old data. Read More »

Posted in PHP, SugarCRM | Tagged , , , , , | Leave a comment

SugarCRM Labels Hierarchy

Labels can seem very straight forward when you’re working within Studio, but when you dive into code you’ll likely find that the system labels for a particular module or for dropdown definitions are strewn throughout several places in the system. Let’s examine the different places for label data and the hierarchy the system uses to compile the labels together and resolve conflicts.

Read More »

Posted in SugarCRM | Leave a comment

SugarCRM Announces Annual Global Partner Awards Program Winners at SugarCon 2012

SugarCRM, the world’s fastest-growing customer relationship management (CRM) company, today announced the winners of the company’s Annual Global Partner Awards Program at SugarCon 2012, the company’s annual customer, user and partner conference. Partners from North America, EMEA, Latin America, Asia, Australia and New Zealand were recognized for their successful growth and new customer acquisition and retention in 2011. More than 40 companies were honored with awards, and two companies were given highest honors as the Partner of the Year and the Rookie of the Year.

The 2011 Partner of the Year Award was granted to Opensymbol. Each year, the award is given to one SugarCRM partner. The criteria for the award is based on the company having more than one year of SugarCRM experience, as well as success in new customer acquisition and customer retention, consistent growth and active participation in SugarCRM’s sponsored events. The partner must also be in good standing and nominated by a regional vice president.

W Systems, based in Ramsey, New Jersey received the Rookie of the Year Award. The company was selected because of their ability to engage quickly with SugarCRM and achieve major milestones since signing their agreement with SugarCRM in November 2011. Within 60 days of signing on with SugarCRM, W Systems secured more than 20 new customers and became a primary evangelist for SugarCRM by becoming the first partner to participate in a partner case study.

The Top Performer Awards were given to 29 companies by region. Each company achieved growth from 2010 to 2011 and secured at least $20,000 in new customer subscriptions with SugarCRM.

In North America, the winners were: Profiling Solutions, Cynergy Solutions, OA Solutions, ATCORE Systems, ApexTwo, Faye Business Systems Group, Technology Advisors, Inc., Concentrix, Highland Solutions, and Plus Consulting. In EMEA, the winners were: Smile Open Source Solutions Group, Corenet, Hubstone, OpenSymbol, Captivea, CS2, Ysance, Dupaco, and dotBase. In Latin America, the winners were: DISYTEL openConsulting, Palmtree Consulting, QuanticVision, and GrowIT. In Australia and New Zealand, the winners were: Innovent, CRM Online, and CRMLogic. In Asia, the winners were: Bhea Technologies Pte Ltd., CRMWorks Asia, and Signify.

The Most Valuable Player Awards were granted to 10 companies by region. Partners were nominated by a Regional Vice President based on their significant customer acquisition year over year and their ability to achieve customer retention of 80% or higher. In North America, the winners were: BrainSell, Epicom, ATCORE Systems, and Levementum. In EMEA the winners were: EnableIT Technologies, Insignio CRM, Synolia, and Jacobsons Direct Marketing. In Latin America, the winner was GrowIT. In Australia and New Zealand, the winner was InsightfulCRM. In Asia, the winner was BHEA Technologies Pte Ltd..

“We are thrilled to see a record number of top performers awarded and want to congratulate all our partners on their achievements,” said Jeff Campbell, Vice President of Worldwide Sales. “They have been diligent in 2011 to meet their business goals and deserve recognition for their accomplishments. We are looking forward to continued success in the channel in 2012.”

Special Recognition Awards were given to BrainSell, Epicom, Highland Solutions, InsightfulCRM, Insignio CRM, iZeno, Lampada Global Services, Levementum, OpenSymbol, Palmtree Consulting, REDK, and Synolia. Both iZeno and Epicom received multiple Partner of the Month Awards in 2011. Amanda Anderson of Epicom was the recipient of the Most Creative Marketer Award.

Please see other SugarCRM announcements from SugarCon about the company’s Q1 2012 momentum, the latest Sugar 6.5 product release, and additions to the company’s channel partner program.

More About SugarCon 2012

SugarCon 2012’s theme is “Explore the Possibilities of CRM,” inspiring attendees to dig deeper into the vast capabilities that CRM offers. In keeping with SugarCRM’s open approach to business, the CRM community, not SugarCRM, built the conference schedule based on attendee suggestions and online voting. The event will offer eight tracks with more than 80 breakout sessions, as well as separate UnCon and training programs.

For more information on SugarCon 2012, visit the event web site. To register for the event, visit the registration page.

About SugarCRM

SugarCRM makes CRM simple. As the world’s fastest growing customer relationship management (CRM) company, SugarCRM applications have been downloaded more than ten million times and currently serve over 1,000,000 end users in 192 countries. Over 7,000 organizations have chosen SugarCRM’s On-Site and Cloud Computing services over proprietary alternatives. SugarCRM has been recognized for its customer success and product innovation by CRM MagazineInfoWorld and Customer Interaction Solutions.

For more information, call (408) 454-6900 or 1 87 SUGARCRM toll-free in the US, email contact@sugarcrm.com, or visit www.sugarcrm.com. You can also connect with SugarCRM on FacebookTwitter and YouTube.

http://www.sys-con.com/node/2260364

Posted in Press Releases, SugarCRM | Leave a comment

Hiding Subpanels, thru Configuration and thru Code

SugarCRM’s subpanels are pretty configurable. Especially in later editions, a single reference to a subpanel can be overridden via Studio very easily. But what if you want to all-out hide a subpanel? Studio doesn’t offer this ability. Enter the Display Module Tabs and Subpanels menu, accessible from the Admin page under the Developer Tools section:

Display Module Tabs and Subpanels

But suppose you didn’t want to hide all of the subpanels for a given module, but just to remove it from a particular view? For a real-life example, we recently had a need to remove the default Opportunities subpanel from the Accounts DetailView. Because it’s only for this view that we want to drop the Opportunity subpanel, the above dialog doesn’t fit the need, and Studio cannot help us either. We must go through code.

Subpanel layouts are defined originally within metadata, e.g. /modules/Accounts/metadata/subpaneldefs.php. These files hold the original, default layout of subpanels and the fields within them. They are overridden in custom Extension data, e.g. custom/Extension/modules/Accounts/Ext/Layoutdefs/accounts_opps.php. After a repair & rebuild, you’ll find the data from the arbitrarily named files are merged and placed in /custom/modules/Accounts/Ext/Layoutdefs/layoutdefs.ext.php.

In these files we can define new subpanels or re-define existing ones. To actually remove one, we can use PHP’s unset function:

<?php
unset($layout_defs["Accounts"]["subpanel_setup"]['opportunities']);

For further example, here is the described code, packaged and ready for distribution via Module Loader:
Accounts DetailView Hide Opp Subpanel

Posted in SugarCRM | Leave a comment

Longer SugarCRM Sessions

In most server-setups, we find that the SugarCRM Session only lasts about half an hour. This is something I’ve gotten complaints about — users wanting longer sessions to ease the work day. I had spent time looking through the session-management code to find an answer and just wasn’t getting anywhere. I back-burned it until I stumbled on the solution today: SugarCRM sets session length according to a PHP configuration variable.

As it often does, the SugarCRM Forums held the question and answer. In extending the 30 minutes session timeout forum user Duzoid posts the question and it is eventually correctly answered by user Sunside. The solution is to modify the PHP configuration variable session.gc_maxlifetime. Sunside suggests placing the changed configuration in an .htaccess file due to accessibility and hosting environment limitations, but having access to my core php.ini I went ahead and changed our local Sugar instance globally.

If it is allowed on your host, then you may very well change this in the .htaccess file:

php_value session.gc_maxlifetime 14400

This should set the session lifetime to 4 hours.

Please note that if session files are shared between different scripts in different directories on your server, then you need to make this setting in each of the script directories’ .htaccess file. That is because other scripts may erase your Sugar session files if they have a shorter session lifetime.

You could also create a separate directory for Sugar session files and set this with

php_value session.save_path /my/new/sugarsessiondir

in the .htaccess that you put in your Sugar root directory. You should NOT create this directory anywhere under your htdocs, but further up in the directory structure, so that these files cannot be accessed by the webserver for security reasons.

The preferred way of setting the garbage collector’s maxlifetime would be to do it serverwide in the php.ini, but this may not be possible in some shared hosting environments.

Posted in SugarCRM | Tagged , , | Leave a comment

Debian Squeeze Apache2 and GoDaddy SSL Certifications (https)

I recently set up my first ssl-certification for Apache for our SugarCRM server. The process wasn’t as difficult as I expected, as Debian has some built in tools to make it relatively easy. Read More »

Posted in Uncategorized | Leave a comment

Four Questions you Should Ask before buy a CRM System

“It is a very bad security model, the roach motels of clouds.  You can check in but you can’t check out. “

Larry Ellison’s quote about SalesForce, Oct 2011

Larry Ellison is the founder of Oracle Software, the second largest applications provider in the world.   First and foremost he is a sales representative.  His quote is very much posturing and positioning.

I reference the quote only because as a consultant, I empathize with my customers being bombarded with statements and promises by Sales people. But how do you make an informed decision?

Many CRM sales representatives want you to buy the system without knowing what’s under the hood.  It would be like buying a car based solely on color and design only to find out afterwards that the engine does not have enough horsepower.

Every CRM has accounts, contacts, opportunities, activity management, leads, a few have quotes, most have custom reporting and dashboards, most integrate with other systems.  Whether you’re considering SugarCRM, SalesForce, Zoho or a plethora others, the basic CRM functionality is generally the same.  So, you might ask, what is the difference? Well, there’s a lot of difference that may not be seen. Here are 4 questions you should ask before buying a CRM system so you know what’s ‘under the hood’ and away from ‘the roach motel’.

  1. Multi-tenant or Single tenant?  Do I own my data?
  2. Is there additional cost for additional CRM functionality?
  3. Are there restrictions regarding the number of custom modules, fields, workflows, etc?
  4. What is the exit plan? How do I get my data back?

Answer 1: Multi-tenant are systems in which multiple ‘customers’ use the same database.  Information is segmented through database security.  A single-tenantsystem is a system were the ‘customer’ has their own database.  Single tenant systems allow you to customization the system more extensively without the restrictions of multi-tenant systems.  In a multi-tenant system, you are sharing a database with others.  Multi-tenant systems place restrictions on the number of fields, modules, integrations, workflows that can be supported.

SugarCRM Answer 1: SugarCRM is a single-tenant system.  Each company has their own database.    And with SugarCRM, you have you choose of where you want to have SugarCRM hosted: the SugarCRM cloud, private cloud, or your own network.


Answer 2:  With almost any other CRM system, the answer is yes.  Extra CRM functionality is additional cost.

SugarCRM Answer 2: With SugarCRM regardless of the SugarCRM version, the CRM functionality is the same.    Differences in  versions is based upon additional support, storage, mobile, and platform options.  But not CRM functionality.


Answer 3: Yes

SugarCRM Answer 3:  There are no limits of any kinds: unlimited modules, unlimited fields, unlimited workflows, unlimited API calls/webservices.


Answer 4:  Some companies will charge you to get a copy of your data or give you a collection of CSV files 4 to 6 weeks later.  Some require that you run reports for each entity and export to Excel.  And some have no way of getting your data back to you.

SugarCRM Answer 4: On request, SugarCRM will give you a copy of your database (not CSV files) and a copy of all the files associated to SugarCRM and at no charge!

Posted in SugarCRM | Leave a comment

PHP and Microsoft SQL Server

There are several methods of getting a PHP-enabled web server talking to your Microsoft SQL Server database. Depending on your requirements and available PHP versions, extensions, though, it can be a tedious process. Effectiveness of a particular solution may vary based on versions of SQL Server and PHP. There are options, though, and I’ll detail a few methods I’ve used to get PHP working with MSSQL. Hopefully one of them will work for you.

First, I’d like to plug a really great software called WAMP Server. WAMP is a pre-packaged Apache Web Server, MySQL Server, and PHP installation. It’s intended for development purposes, but it can just as easily be sat on a production box after some minor configuration changes. The neat feature in WAMP is that you can download additional versions of PHP; switching between versions is easily done via right-clicking an icon in the Windows system tray. Additionally, PHP extensions can be toggled on or off from the same menu. That’s a big deal if you want to make sure your code works in PHP 5.1, 5.2 and 5.3, or even check PHP 4 support. That said, XAMPP is a similar tool that has all of the functionality of Apache, MySQL and PHP bundled up, but it’s a little less easy to drop in support for separate versions of PHP.

Note that both of those software come packaged with MySQL Database Server. The point here is to use MSSQL, so you’ll probably want to disable the mysqld service.

Option 1, mssql

PHP actually has a pre-bundled extension mssql or php_mssql. This gives the developer the ability to connect to a database, run queries and return query results. Very nice, if you can get it to work. I’ve found that recent versions of PHP running on WAMP (specifically 5.2.9, 5.3.1, 5.3.4, 5.3.5) simply will not connect to my locally-installed MSSQL Server running 2008. Some versions don’t appear to have the php_mssql extension packaged. I don’t really know if this is a failure to compile things from the distributors of WAMP or if there’s a more-upstream issue, but it doesn’t work. What does work for me is WAMP and PHP Version 5.2.11. Grab it from WAMP’s Sourceforge Page.

Switching to PHP 5.2.11 and enabling the php_mssql extension via the UI is all I had to do to make my mssql_connect and mssql_query functions work. The down-side is that I’m stuck in PHP 5.2 and miss out on some of the cool new functions in 5.3.

I have probably 10 different versions of PHP installed on my machine, and 5.2.11 is the only one that works. Your mileage may vary, I’m guessing drastically based on your version of SQL Server.

Option 2, ODBC

ODBC support is built in to every version of PHP since PHP4. It’s basically a standardized way of connecting to and working with databases, and it works great. The down side of ODBC is that it’s said to be slower than the new OLE-DB. I maintain one PHP-based portal using ODBC and customers do not complain; like everything else, performance very depends on your resources and requirements.

Using ODBC, you’ll have to specify a specific connection string. Here’s a quick way of doing that:

function db_connect($host,$user,$pass,$db){
	// This connection string is used on the production box, Windows Server 2003
	// and SQL Server (hosted spearately but also Win 2003) version 2005
	$dsn = "Driver={SQL Native Client};Server=$host;Database=$db; Uid=$user;Pwd=$pwd;";
	// This is a more generic one I use with to dev with, Windows 7 and SQL Server 2008
	$dsn = "Driver={SQL Server};Server=$host;Database=$db"; // only for dev. purposes

	try{
		$conn = odbc_connect($dsn, $user, $$pass);
	}catch (Exception $e){
		die('Could not connect to database.');
	}
	return $conn;
}

Option 3, OLE DB and/or Application-Specific Providers

I recently worked with a Sage SalesLogix portal that needed to take advantage of some application-specific functions within an OLE DB Provider shipped from Sage. I was capable of using the MSSQL database functions directly with ODBC or mssql with above methods, but to access the extra functions I had to use their provider. This can only be done using Windows boxes because we must leverage the PHP COM Class. This works similarly to the ODBC connection but methods’ names are a bit different and, in my opinion, less intuitive. Here’s a sample from my database-connecting class that used an OLE DB-based COM Connection.

class oledb_database{
	var $user;
	var $pass;
	var $db;
	var $connection_string = 'Provider=SLXOLEDB.1;Data Source=localhost;Initial Catalog=$db;User Id=$user;Password="$pass";Persist Security Info=True;Extended Properties="PORT=1706;LOG=ON;"';
    var $rows_count;

    function connect(){
        if(!class_exists('COM')){
            die("COM Class could not be found. Please run system from a Windows-based PHP system.");
        }
        $conn = new COM("ADODB.Connection") or die("Cannot start ADO");
        global $config;
        try {
            $conn->Open($connection_string);
            $this->link = $conn;
            return true;
        } catch (Exception $e) {
            echo 'Caught exception: ',  $e->getMessage(), "<br>\n";
            return false;
        }
    }
    function query($query){
        try {
            $this->result = $this->link->Execute($query);
            $this->rows_count = $this->result->Fields->Count();
            return $this->result;
        } catch (Exception $e){
            echo 'Caught exception: ',  $e->getMessage(), "<br>\n";
            echo "<h3>$query</h3>";
            die();
        }
    }
}

The OLE DB method felt much more cumbersome, but in the end it had nice exception handling and worked fine (once I got the connection string right).

Conclusion

Your options are native mssql support if you can manage it, classic ODBC and or modern OLE DB connections. Surely one of these methods will allow you to connect and work with your data.

There is one final method for connecting to MSSQL databases that I am aware of, and it is FreeTDS. This is really a project geared to getting MSSQL connectivity supported in Linux-based Apache systems and is known to be difficult to work with. If you must use a Microsoft SQL Server database, you will have a easier time with things if you work with a Windows-based Apache and PHP configuration with one of the above methods.

Posted in PHP, Web Customization | Leave a comment

Creating Saleslogix IDs in PHP

One of the fundamental aspects of working with any particular database-driven system is to understand how to properly create new records, and the most crucial aspect of that, as any amateur or pro DBA knows, is using proper table IDs. The Saleslogix ID system is 12 characters long, compromised of a leading-letter code to identify the record to a particular table, a 4-character “site code” and a 7-character base-36 encoded incrementing numerical ID string. The most-recent IDs for a given module are kept in a sitekeys table for reference for the next record. Don’t panic. It’s not that bad. Read More »

Posted in SalesLogix | Leave a comment

Sage President\

Profiling Solutions, Inc
174 Carroll Street
Atlanta, GA 30312
Sales: 1 (866) 515-9959
Office Phone: (404) 525-8003
Office Fax: (404) 525-8005
info@profilingsolutions.com