function mobile_codes_generate in Mobile Codes 7.2
Same name and namespace in other branches
- 5 mobile_codes.module \mobile_codes_generate()
- 6.2 mobile_codes.module \mobile_codes_generate()
- 6 mobile_codes.module \mobile_codes_generate()
Cache a Mobile Code.
Parameters
$url: A processed Mobile Code URL.
Return value
The path of the cached Mobile Code if request is successful, and FALSE if it isn't.
2 calls to mobile_codes_generate()
- mobile_codes_mobile_codes_tokens_alter_alter in includes/
mobile_codes.inc - Implements hook_mobile_codes_tokens_alter_alter().
- theme_mobilecode in ./
mobile_codes.module - Theme function for displaying Mobile Codes
File
- ./
mobile_codes.module, line 143 - Mobile Codes core functions.
Code
function mobile_codes_generate($url) {
$settings = mobile_codes_defaults();
if (!file_exists($file = $settings['general']['path'] . '/' . md5(serialize($url)) . '.png')) {
$request = drupal_http_request($url);
if ($request->code == 200) {
$directory = $settings['general']['path'];
if (file_prepare_directory($directory, FILE_CREATE_DIRECTORY)) {
file_unmanaged_save_data($request->data, $file);
}
}
else {
return FALSE;
}
}
return $file;
}