Friday, February 18, 2011

Nokia mobile shortcuts

By pressing x + # (where x is any number) will
show thetelephone
number stored in that particular location.

For example, pressing 125 in idle mode and then pressing
"#" later,
will show the 125th number stored when the number are
entered in your
phone-book.


*3370#
Activate Enhanced Full Rate Codec (EFR) - Your phone uses
the best
sound quality but talk time is reduced my approx. 5%

#3370#
Deactivate Enhanced Full Rate Codec (EFR) OR *3370# ( Favourite )

*#4720#
Activate Half Rate Codec - Your phone uses a lower quality sound but
you should gain approx 30% more Talk Time.

*#4720#
Deactivate Half Rate Codec.

*#0000#
Displays your phones software version,
1st Line : Software Version,
2nd Line : Software Release Date,
3rd Line : Compression Type. ( Favourite )

*#9999#
Phones software version if *#0000# does not work.

*#06#
For checking the International Mobile Equipment Identity
(IMEI Number).
( Favourite )

#pw+1234567890+ 1#
Provider Lock Status. (use the "*" button to obtain the
"p,w" and "+"
symbols).

#pw+1234567890+ 2#
Network Lock Status. (use the "*" button to obtain the
"p,w" and "+"
symbols).

#pw+1234567890+ 3#
Country Lock Status. (use the "*" button to obtain the
"p,w" and "+"
symbols)

#pw+1234567890+ 4#
SIM Card Lock Status. (use the "*" button to obtain the
"p,w"and "+"
symbols).

*#147#
(vodafone) this lets you know who called you last.

*#1471#
Last call (Only vodofone).

*#21#
Allows you to check the number that "All Calls" are
diverted to


*#2640#
Displays security code in use.

*#30#
Lets you see the private number.

*#43#
Allows you to check the "Call Waiting" status of your phone.

*#61#
Allows you to check the number that "On No Reply" calls are
diverted to.

*#62#
Allows you to check the number that "Divert If Unreachable
(no
service)" calls are diverted to.

*#67#
Allows you to check the number that "On Busy Calls" are
diverted to.


*#67705646#
Removes operator logo on 3310 & 3330
..
*#73#
Reset phone timers and game scores.

*#746025625#
Displays the SIM Clock status, if your phone supports this
power saving
feature"SIM Clock Stop Allowed", it means you will
get the best standby time

possible.

*#7760#
Manufactures code.

*#7780#
Restore factory settings.

*#8110#
Software version for the nokia 8110.

*#92702689#
Displays -
1.Serial Number,
2.Date Made,
3.Purchase Date,
4.Date of last repair (0000 for no repairs),
5.Transfer User Data.
To exit this mode you need to switch your phone off then
on again. (
Favourite )

*#94870345123456789 #
Deactivate the PWM-Mem..

**21*number#
Turn on "All Calls" diverting to the phone number entered.

**61*number#
Turn on "No Reply" diverting to the phone number entered.

**67*number#
Turn on "On Busy" diverting to the phone number entered.

Friday, February 4, 2011

Getting URL Parameter / Arguments Values

Explode Functions is used to get the parameter or arguments from url in drupal

$pieces = explode('/', $_GET['q']);

where

  • $pieces is the variable where the url is splitted and stored as an array.
  • $_GET['q'] will contain the url address
Points to remember
  • Values will be splited against '/'
  • $pieces[1] will contains the first parameter after splitting
Explode function can also be used to split any normal Variable
  1. for eg. if $abc='India-Wins'
  2. $xyz = explode('-', $abc); // the variable is splitted against '-' (hipen)
  3. now $xyz[0]='India' and $xyz[1]='Wins'

Methods to Pass Values through URL in Drupal

Two Ways of Passing Values through URL are mentioned here for Drupal

I) goto

drupal_goto('sample/'.$xyz.'/'.$abc.'/'.$lmn);

where
  • sample is the page where u have to navigate
  • $xyz,$abc,$lmn are the variables you are passing to that page.
Points to remember

  1. You can either store values in variable and send them or do it directly by mentioning the value instead of the variable there
  2. You can also use this to simply navigate to same page or some other page even without using variables(make sure u don't use slash at the end)
eg : drupal_goto('sample');

II) a href (traditional method)


  1. <@ href=\'?q=sample / ' . $abc.'\'>
  2. Update General Details
  3. < / @ >
where
  • @ means 'a'
  • $abc is an variable
  • User can give his own wordings instead of "Update General Details"
  • When User Clicks on Update General Details , the page will be navigating to the sample page with the value.
Difference Between The Both I & II

  • goto gets executed with the control reaches there.
  • a href get executed only when the user cliks on it

-------------------------

https://amzn.to/44VdtxB


Multiple Submit Buttons in Same Form

When using multiple submit button in same form one must ensure that the corresponding functions are called for each submit buttons in drupal.

Sample coding for calling specified function is given below.

  • Both the buttons are of the same type submit (given in red color)
  • but the corresponding function is invoked . (given in green color)

function abc_form($form_id, $form_state=NULL) {
// code
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#submit'=>array('abc_submit'),
);
$form['update'] = array(
'#type' => 'submit',
'#value' => t('update'),
'#submit'=>array('abc_update'),
);

retun $form;
}

function abc_submit($form_id, $form_state)
{
// this function is called when the submit button is clicked
// code
}


function abc_update($form_id, $form_state)
{
// this function is called when the update button is clicked
// code
}

Confirmation Box On Submit

Here is a sample coding for generating Confirm Box on clicking a submit..

  • The form gets submitted only after user approves it.
  • You can just add the following lines of coding as attributes in your form element.
  • If the user clicks on 'NO', the form is not submitted
Important Lines are highligted in red color.

$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#attributes' => array('onclick' => ('if(confirm("Are you sure you want to submit the form")) return true; return false')),
);

Saturday, January 29, 2011

Uploading Files in Drupal

  1. function invoice_perm()
  2. {
  3. return array('access content invoice');
  4. }

  5. function invoice_menu(
  6. {
  7. $items['invoice'] = array(
  8. 'title' => 'Invoice Entry',
  9. 'page callback' => 'invoice_editpage',
  10. 'access callback' =>'user_access',
  11. 'access arguments' => array('access content invoice'),
  12. 'type' => MENU_NORMAL_ITEM,
  13. );
  14. return $items;
  15. }

  16. function invoice_editpage()
  17. {
  18. $output = t('Invoice Entry Form.');

  19. // Return the HTML generated from the $form data structure.
  20. $output .= drupal_get_form('invoice_nameform');
  21. return $output;
  22. }

  23. function invoice_nameform($form_id, $form_state = NULL)
  24. {

  25. //File Refernce name

  26. $form['invoice_title'] = array(
  27. '#type' => 'textfield',
  28. '#title'=>t('Invoice Title'),
  29. '#size'=>20,
  30. );

  31. $form['#attributes'] = array('enctype' => "multipart/form-data");
  32. $form['invoicefileattachment'] = array(
  33. '#type' => 'file',
  34. '#title' => t('Browse the Scan copy of the invoice'),
  35. '#required' => FALSE,
  36. '#size'=>20,
  37. '#default_value' => $form_state['values']['invoicefileattachment'],
  38. );
  39. $form['submit1'] = array(
  40. '#type' => 'submit',
  41. '#value' => t('Register'),
  42. );
  43. return $form;
  44. }

  45. function invoice_nameform_submit($form_id, $form_state)
  46. {

  47. global $user;
  48. profile_load_profile($user);
  49. $uid=$user->uid;
  50. $empid=$user->employee_code;
  51. $userip = $_SERVER['REMOTE_ADDR'];
  52. $dt=date('Y-m-d H:i:s');
  53. $state_code=$user->state_code;

  54. if($state_code==30)
  55. $abc='TR';
  56. else
  57. $abc='TN';

  58. $limits = array () ;
  59. $invoice_title = $form_state['values']['invoice_title'];
  60. $po_title=$form_state['values']['po_title'];
  61. $path123=file_directory_path();


  62. $file = file_save_upload('invoicefileattachment', $validators, file_directory_path());

  63. $filename = $file->filename;
  64. $src = file_directory_path() . '/' . $filename;
  65. $dest = $abc.'/'.$filename;
  66. $path_file=$path123.'/'.$abc.'/'.$filename;

  67. if(isset($filename))
  68. {
  69. file_copy($src, $dest, FILE_EXISTS_REPLACE);
  70. file_delete($path123.'/'.$filename);
  71. drupal_set_message (" Invoice File saved", "status");
  72. file_set_status ($file, FILE_STATUS_PERMANENT);
  73. db_query("INSERT into drupal_txn_file_upload(uid ,
  74. filename,
  75. filepath,
  76. filesize,
  77. state_code,
  78. category,
  79. timestamp,title)
  80. VALUES('%d','%s','%s','%d','%d','%s','%d','%s')",$uid,$filename,$path_file,$file_size,$state_code,$category,time(),$invoice_title);
  81. }

Simple Form in Drupal

  1. function transport_services_perm() // used for setting permission
  2. {
  3. return array('access content transport_services');
  4. }

  5. function transport_services_menu() // creating menu
  6. {
  7. $items['transport_services'] = array(
  8. 'page callback' => 'transport_services_page',
  9. 'access arguments' => array('access content transport_services'),
  10. 'access callback' =>'user_access',
  11. ); return $items;
  12. }

  13. function transport_services_page()
  14. {
  15. $output='Welcome to R';
  16. $output .= drupal_get_form('transport_services_form1');
  17. return $output;
  18. }

  19. // Actual form being defined here....

  20. function transport_services_form2($form_id, $form_state = NULL)
  21. {
  22. $form['reg_no'] = array(
  23. '#title' => t('Registration Number:'),
  24. '#type' => 'textfield',
  25. '#size' => '25',
  26. '#required' => TRUE,
  27. '#prefix' => '
    ',
  28. '#suffix' => '',
  29. );
  30. $form['reg_name'] = array(
  31. '#title' => t('Registration Name:'),
  32. '#type' => 'textfield',
  33. '#size' => '25',
  34. '#required' => TRUE,
  35. '#prefix' => '
    ',
  36. '#suffix' => '',
  37. );
  38. $form['submit'] = array(
  39. '#type' => 'button',
  40. '#value' => t('Submit'),
  41. '#validate' => array('transport_services_renewal_output')
  42. );
  43. return $form;
  44. }
  45. // Submit Function is defined....

  46. function reusable_services_form1_submit($form_id,$form_state)
  47. {
  48. $reg_no = $form_state['values']['reg_no'];
  49. $reg_name = $form_state['values']['reg_name'];
  50. db_query("INSERT INTO {registration} (registration_no) VALUES('%d','%s')",$reg_no,$reg_name);
  51. drupal_set_message(t(“No==>”.$reg_no));
  52. drupal_set_message(t(“Name==>”.$reg_name));
  53. drupal_set_message(t(“Successfully inserted values”));
  54. }