Tamer Zoubi @ Drupal 8


Drupal expert | Programmer

Send SMS from VoIP Drupal

Considering you configured your VoIP Drupal with one of the providers, here is the sample code snippet that sends "Hello world" SMS:

<?php
$number = '+1234567890123'; //Number to send SMS to. Must be in E.164 format.
$call = new VoipCall();
$call->setDestNumber($number);
$text = 'Hello from VoIP Drupal';
voip_text($text, $call);
?>

Pretty cool, right?

Tags
php
sms
VoIP Drupal

Drupal Balkan Summit: VoIP Drupal and building SMS service using any local phone number

Last week I held a session in Drupal Balkan Summit about VoIP Drupal and building SMS service using any local phone number.

In the video below you can see how to use Envaya SMS with VoIP Drupal in order to build SMS service which can receive and send text SMS messages using your local SIM number.

Tags
Drupal7
SMS envaya
SMS Framework
VoIP Drupal
Drupal Balkan summit

Drupal 7 check if user is logged in from javascript

Drupal 7 comes with jquery cookie plugin which can be find under

misc/jquery.cookie.js

This plugin can be used to check if user is logged in or not directly from Jquery. We do that by checking if the cookie DRUPAL_UID exists and its value is not equal to 0.

Tags
anonymous
authenticated
COOKIE
Drupal 7
drupal_uid
javascript
jquery
jQuery.cookie is not a function
user

Theming Drupal 7 user login page

Since I didn't find a good tutorial for theming the Drupal login page I wrote one here.

Getting a page template for the user login page should be as easy as copying your page.tpl.php file and renaming it to page--user-login.tpl.php. Problem is when I tested this It didn't run on /user but only on /user/login page. To get the same template file to run on both you must add to your template.php:

Tags
Drupal 7
theming

Submit Drupal user registration form to Hubspot

Today I am going to show you how to create a small module that submits results of Drupal user registration form to Hubspot. For those who doesn't know, HubSpot provides advanced targeting marketing and lead nurturing features. You can read more about it at their website: http://www.hubspot.com/

We will call our module hubspot_user.module. First of all we need to create admin configuration form where you can enter three things:

Tags
Drupal
Hubspot

Submit a form using Javascript

Usually form is submitted when the user press on a submit button. But , sometimes, you may need to submit the form programmatically using JavaScript.

JavaScript provides the form object that contains the submit() method. Use the 'id' of the form to get the form object.

For example, if the name of your form is 'myform', the JavaScript code for the submit call is:

document.forms["myform"].submit();


But, how to identify a form? Give an id attribute in the form tag:

Tags
javascript

Check if a file exists in Amazon S3

If you are looking for a way to check if a file exists in Amazon S3 bucket using Amazon S3 PHP library, then probably this may help you.

Simplest way is to use function getObjectInfo()

<?php
//initiate the class
$s3 = new AmazonS3();
$info = $s3->getObjectInfo($bucket, $filename);
if ($info){
//File exists
}
else{
//File doesn't exists
}
?>

This function will return FALSE if $filename doesn't exists in Amazon S3 bucket.

Tags
php
Amazon S3

Open Drupal modules in Notepad++ using PHP markup

If you are working everyday with Drupal module development you know how frustrating can be that each time you open a module file its show in plaintext instead of in PHP format. Well there is a easy solution, open up your Notepad++ and go to Settings -> Style Configurator.

Depending on which language color syntax you want for the file extension, under Language, select the language.

Select php under Language.

Tags
notepad++
php
drupal module

PHP convert image to byte array

Recently I worked on integration between Drupal CMS with backend SOAP service and encountered a problem with saving image to the backend. The backend required image to be passed as byte array. Googling around I was suprised to find out answers like "I don't think PHP has such low level control..." or "change your backend service...". Eventually after not finding anything useful I decided to tackle the issue myself and soon I came up with a solution which is actually very easy.

Tags
Drupal 6
php
SOAP