a17g.com

Javascript Oddities

by on Oct.15, 2009, under Uncategorized

When working on certain projects I always come across certain JavaScript oddities which can take some time to resolve.  I’ve never actually taken the time to write them down but I figured it’s a good idea to keep me or others from kicking the dog out of frustration.  In no particular order here they are:

TinyMCE:

If you’re trying to load tiny dynamically meaning your using yui loader or something else to pull in the js file, you’ll need to add the following line before your init method:

tinymce.dom.Event.domLoaded = true;

The reason why?  Tiny attaches a listener to the window which is supposed to be fired when the dom is ready.  However, if you load the js dynamically the event is never triggered.

Leave a Comment more...

Compiling imap c-client on ubuntu

by on Oct.01, 2009, under Uncategorized

make slx SSLINCLUDE=/usr/include/openssl/

sudo cp c-client/*.h /usr/include/
asandberg@asandberg:~/downloads/imap/imap-2007e$ sudo cp c-client/*.c /usr/lib/
asandberg@asandberg:~/downloads/imap/imap-2007e$ sudo cp c-client/c-client.a /usr/lib/libc-client.a

Comments Off more...

Compiling in SVN for php

by on Jul.21, 2009, under php

Need svn support within php?  If so, pecl is currently housing a beta package that is available.  To install,perform teh following steps:

1.  Download the latest release from here: http://pecl.php.net/package/svn

2. Untar the source ball

3.  go into the new svn directory and run phpize

4.  perform the ./configure && ./make && ./make install

5.  Edit your php.ini file to point to the new linked object.

Now you can enjoy svn functions from your php scripts!

Comments Off more...

SugarCRM – Bean Loading

by on Apr.21, 2009, under Software, SugarCRM

Ever need to load in a Sugar bean but can’t remember if the directory name is the same as the bean name is the same as the php file containing the bean?  Don’t worry you’re not alone.  This was a design flaw that has propogated even into the latest versions of sugar.  But there’s an easier way.  Rather than requiring_once the full path of the php file housing the bean, use the following snippet:

$beanname = ‘Contact’;
require_once($GLOBALS['beanFiles'][$beanname]);
$focus = new $beanname;

Substitude beanname for whatever you want and bingo.  This will also help ensure that with future versions of sugar when they add the ability to sublcass and extend in beans you’re loading the correct version.

1 Comment more...

SugarCRM JSON Object

by on Apr.20, 2009, under Software, SugarCRM

Need a json object to output json encoded data?  Use the following code sample, the json object is automiatcally included in when the application is started so no requires are needed:

$json = getJSONobj();
$out = $json->encode($ret, true);

@ob_end_clean();
ob_start();
echo $out;
ob_end_flush();

Comments Off more...

SugarCRM Dates

by on Apr.20, 2009, under Software, SugarCRM

Some sugar related date functions:

Get the current date time stamp in a database agnostic fashion:

gmdate($GLOBALS['timedate']->get_db_date_time_format());

You’ll notice we use the gmdate function since all dates within sugar are stored in the gmt timezone.  The conversions to the user format and timezone are applied when the SugarBean retrieve function is executed.

To convert from db to display format use:

$display_now = $GLOBALS['timedate']->to_display_date_time($now);

Where $now is the db version of gmdate.

Comments Off more...

Joomla – Templates And Layouts

by on Apr.13, 2009, under Joomla

In the process of learning the ropes regarding customizing Joomla.  What I’ve found so far has been promising but also disappointing.  Working on the 1.5 code base, there is currently no way to safetly overide any language pack entries.  Meaning any changes you make will be affected when you upgrade the system.  Supposidely 1.6 will address this issue.  I’ll keep posting little tidbits of info with regards to what I find….  Perhaps one day I’ll createa  cohesive tutorial but I doubt that.

What I really wanted with Joomla was a CMS system that I could hack to hell and that I could use to easily automate the setup, data propogation, and deployment.  Why you ask?  Well, I’m trying to take advantage of affiliate commissions and am trying to mash some things together.  In the process I found that I needed to modify how sections, categories, and components are displayed.  Here’s what I’ve found so far.  If you need to modify how a component is displayed you can simply copy the default views provided by the system into the theme that you are using.  Then you can customize this file to your needs.  The benefits to this approach is that you can then simply zip up and deploy your themes with your customizations which makes things slighly easier at least in my opinion.  You could modify the core file but why worry about upgradability in the future.  For my needs I simply copied in the default.php file from the components/views/section/tmp directory into my theme.

Comments Off more...

Hijack SugarCRM’s Relate Fields

by on Feb.21, 2009, under Software, javascript

Sugar has a Relate type field which can be added on the EditView layout.  This field works great for selecting related records from a seperate module.  There are really two ways to make a selection, the user can start typing and an auto-fill functionality will kick in.  Or, they can use the select button which opens a seperate window.  Well, what if we want to apply a callback function afterwards to perform some processing.  How do we do that?  Well, here’s the easiest way, just copy and paste.  Since it’s a Firday night, I’ll update the explanation later:

sqs_objects['account_name']['post_onblur_function'] = ‘set_after_sqs’;

/**
*  Call back function after auto-fill.  Cannot pass in an anonymous function do to bad coding on sugars part.
*/
function set_after_sqs()
{
handleCalculations();
}

/**
*    Since we can’t pass in another call back function to the popup window we are appending to the
*   exisiting functionality.
*/

var tmpSetReturnFunc = set_return;
set_return = function(popup_reply_data)
{
tmpSetReturnFunc(popup_reply_data);
handleCalculations();
}

Ext.onReady(init);

2 Comments more...

Adding custom meta data files to Sugar the upgrade safe way.

by on Feb.11, 2009, under Software, SugarCRM

SugarCRM uses a notion of metadata files to provide two purposes:

  1. Define relationships between beans
  2. Create the necessary table structures used to manage this relationships.

All of the metadata files for the oob modules are stored in the root/metadata folder.  The files are ‘registered’ in the TableDictionary.php which is located in the modules directory.  If you need to add custom meta data files you can create them and add them to the custom/metadata directory.  You will probably need to create this directory yourself.  In order to register these new dictionary entries you can simply create a file and add them in here:

‘custom/application/Ext/TableDictionary/tabledictionary.ext.php’

This will ensure that your entries are all upgrade safe.

Comments Off more...

SugarCRM – Getting a database object

by on Jan.20, 2009, under Software, SugarCRM

On ocassion it becomes necessary to query the database for whatever particular reason.  If you are extending a bean object then you already have a db object availabile to you from the instance variable $db.  So you could access the database object by referncing it like this:

$this->db->query(“Select * from something”);

If however you are extending other files and need access a database object the recommended approach is to make the following call:

$db = DBManagerFactory::getInstance();

This is a bit safer than just using the global db variable as the getInstance implements the singleton pattern and will always return a valid db object.  Unless of course your configuration file does not point to a valid database.

Comments Off more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Archives

All entries, chronologically...