Send SMS with PHP.

php-smsRecently I had a customer’s requirement to send an sms from his web portal.

The SMS gateway that he was using didn’t had that meaningful documentation.After planning on how do I connect to the SMS Gateway , I decided to use PHP cURL.

PHP cURL is a very efficient and powerful library that allows you to connect and communicate to different servers.For more information on cURL visit .

The below code connects to the SMS gateway and then sends the message.

$url = "http://smsurl/sms1"; // URL of the SMS Gateway
$curl_connection = curl_init($url); //Initialize curl handle
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); //Set the post variables like username , password , sms text etc.
$result = curl_exec($curl_connection); //run the whole process and return the response
curl_close($curl_connection);  //close the curl handle

In the above code first the connection to the SMS Gateway is made.
Then the variables like username,password etc is passed.
These parameters and url are given by the SMS Gateway Provider.
The URL is then executed and finally the connection with the Gateway is closed.



allows you to connect and communicate to many different types of servers.. – See more at:
very impressive library that allows you to connect and communicate to many different types of servers – See more at:
very impressive library that allows you to connect and communicate to many different types of servers – See more at:




Create User and Grant Permissions in MySQL.


Normally we do a whole lot of things with the MySQL root user who have full access to all the Databases.

However, in the cases where more restrictions may be required, there are ways to create users with custom permissions.

In this post we’ll go through how to create a new MySQL user and provide him with specific permissions.

How to create a new user.

Let’s first start by creating a new MySQL user.
[sourcelang =’sql’]
CREATE USER newuser@’localhost’ IDENTIFIED BY ‘password’;

Just creating the user doesn’t mean that the user will now get access to MySQL.Unfortunately, at this point even if the user tries to login will be unsuccessful.

Therefore we need to provide privileges to the user.

Set Privileges

[sourcelang =’sql’]
GRANT ALL PRIVILEGES ON *.* TO ‘newuser’@’localhost’;

Here first asterisk means the database  and second asterisk means the tables.So the above command will provide ALL(read,update,delete etc) privileges to newuser on all Databases and all tables.

You can replace these asterisk according to your requirements Eg : schoolDatabase.* or schoolDatabase.students.

Once done with providing specific privileges remember to reload the privileges.


To provide particular permission to a user you may use.

GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@’localhost’ (Refer below for possible permissions.)

To revoke the permissions use

REVOKE [type of permission] ON [database name].[table name] FROM ‘[username]’@’localhost’;



  • If you want the MySQL server to be accessed remotely you may replace localhost with the IP address of the remote machine.
  • If you want the database to be accessed remotely from all IP addresses replace localhost with %.
  • Possible permissions are ALL PRIVILEGES,SELECT(read the database),INSERT(insert rows to a table),DELETE(delete records from a table),UPDATE(update rows of a table),DROP(drop the whole table),CREATE(create a new table),GRANT OPTION(grant or remove other user’s privileges).
  • Each time you update or change a permission be sure to use the Flush Privileges command.

Run Scheduler without accessing Cron.

Cronless Job


To run a Scheduler you need to add an entry in cron.Many times hosting provider limits cron usage and without an entry in cron the Scheduler wont run.

However there is an easier way out as show in the below steps.

If you are using SugarCRM you will have to follow step 3 else the first two steps will suffice.


  1. Setup a cronjob at a free cron provider like or .
  2. Point them to the cron.php to your SugarCRM directory. For example http://yourdomain/SugarCRM/cron.php
  3. Comment the code as shown below in cron.php and save it. You dont need to this if you are not using SugarCRM.
                       //$sapi_type = php_sapi_name();
                     //if (substr($sapi_type, 0, 3) != 'cli') {
                        //    sugar_die("cron.php is CLI only.");


Now when the cron.php is visited on scheduled time it will trigger the Scheduler.

Isn’t it an awesome way to execute the Scheduler.Thanks to the cron providers.





Remove Create Action button.

At times you will have a requirement to remove Create or any other action from menu of a particular module.

My module requires only to list the data and not allow creation or import of data.This can be simply achieved simply by changing some files of the modules.You just need to have access to the files of the module.

To remove the create and import action from the menu do the following :

Open Menu.php of the module and just comment or remove the actions you dont want.


Here you may see that the add and import actions have been removed from the menu and the only available option is list action.

Though the user can access the EditView by passing required parameters in the URL.

Eg : localhost/sugarcrm/index.php?module={module}&action=EditView.

If you want to disable or disallow such an access follow below steps.

  1. Create view.edit.php at custom/module/{module}/views/view.edit.php
  2. Write the following code therein.
  class User__User_ActivityViewEdit extends ViewEdit{
    function display(){
              sugar_die('You cannot create new records here, sorry'); 

Now if the user still tries to access the edit view below screen will be displayed.

editview disabled
EditView Disabled























Disable Edit Link from ListView

SugarCRM module’s List View comes with default options like an edit view link and  a checkbox besides it.

Many times users feels a need to hide the link and/or checkbox.However this cannot be done from SugarCRM admin panel,but you can do it if you have access to its files.

Create a file called view.list.php at custom/modules/{module}/views/view.list.php and write the code below.If you have the file view.list.php at
modules/{module}/views/ copy it to custom/modules/{module}/views else create a new one in custom.

Write the below code therein.

class {module}ViewList extends ViewList
    function {module}ViewList()
    function Display()
        $this->lv->quickViewLinks = false; // Removes Edit View Link
        $this->lv->multiSelect = false; //    Removes Check Box     







Test your addon on SugarCRM On-Demand.


Sugar On-Demand comes with a lot of module loader restrictions which might make your module installation a complete failure.I faced the same issue when installing the addon I created and installing it on Sugar On-Demand.

You have created a great module but will it work on Sugar On-Demand is big damn question.

Thankfully you can test this on your local SugarCRM environment and save the programming and support time later.

You just need to set package scanner  to be true.

To do this simply add the following line to your config_override.php file.

$sugar_config['moduleInstaller']['packageScan'] = true;


Now when you you install the package it will work same as it will do it on Sugar On-Demand version.

It will then return all the issues found in the package that makes it incompatible with On-Demand version.





Change SugarCRM Admin Password with SQL

Reset Password

Suppose you or someone else have installed SugarCRM ,but you are not able to get  its access , the only wayout is to change/reset the admin password via SQL.

Get into the respective database and find table users.Firstly you will have to find the active admin account.

The active admin account is one whose is_admin column is set to 1 and the column status is set to  active .

The below sql query displays all active admin users.

SELECT user_name FROM users WHERE is_admin = '1' AND status = 'Active';

The password is simply a md5 hash, therefore you can set it to any value you like via:

UPDATE users SET user_hash = MD5('PASSWORD') WHERE user_name = 'USERNAME';


Make custom EditView work for Quickcreate.


In this article I will show you how you can make your Custom EditView of any module also work for quickcreate via subpanels.

This took me way too long to figure out as well and I am happy to share the quite easy answer with you!

In your custom view.edit.php file add the following line inside the __construct() method:

$this->useForSubpanel = true;

The above code will make custom edit view functions to also work for quickcreate.


How to create a Custom Scheduler in SugarCRM

SugarCRM comes with its pre-defined Schedulers which you can set from Admin->Schedulers.Schedulers comes into place when you want to perform a recurring job .It is just as Linux Crontab.

CRM Scheduler

To create a custom scheduler you can use the Ext framework of Sugarcrm.

STEP 1 : Create a file MyJob.php in custom/Extension/modules/Schedulers/Ext/ScheduledTasks/ with the following code therein

$job_strings[] = 'MyJob';
 function MyJob(){
 //this is where you put the custom code

STEP 2 : The next step is to create a language file for our custom scheduler.Create en_us.MyJob.php in custom/Extension/modules/Schedulers/Ext/Language/ with the following code

$mod_strings['LBL_MYJOB'] = 'My Custom Job';

STEP 3 : Do a Quick Repair and Rebuild . Your custom scheduler will now be available in the Scheduler dropdown list.After which you can set its execution interval.


Creating custom Scheduler via _AddJobsHere.php is not recommended.Its a shared file and any other customizations can simply override your scheduler.The safest way is to use the Ext framework discussed above.However you will have to use _AddJobsHere file for Sugar Version less than 6.4.