| 395 |
|
|
| 396 |
// create a token |
// create a token |
| 397 |
$token = substr(drupal_get_token(time()), 0, MM_FTP_TOKEN_LENGTH); |
$token = substr(drupal_get_token(time()), 0, MM_FTP_TOKEN_LENGTH); |
| 398 |
|
|
| 399 |
// save the token |
// save the token |
| 400 |
db_query('INSERT INTO {media_mover_ftp_tokens} (uid, token, date) VALUES (%d, "%s", "%s")', $user->uid, $token, time()); |
db_query('INSERT INTO {media_mover_ftp_tokens} (uid, token, date) VALUES (%d, "%s", "%s")', $user->uid, $token, time() ); |
|
|
|
|
// create a subject |
|
|
$subject = t('[!sitename] Your FTP token', array('!sitename' => variable_get('site_name', 'Drupal'))); |
|
|
// create the body |
|
|
$body = variable_get('mm_ftp_email_text', t('Your token is: [token]')); |
|
|
|
|
|
$search = array('[token]', '[user name]', '[site name]', '[site url]'); |
|
|
$replace = array($token, $user->name, variable_get('site_name', '' ), url('', null, null, true)); |
|
|
$body = str_replace($search, $replace, $body); |
|
| 401 |
|
|
| 402 |
// email the user the token |
// email the user the token |
| 403 |
drupal_mail('media_mover_ftp', $user->mail, $subject, $body); |
drupal_mail('media_mover_ftp', 'ftp_token', $user->mail, user_preferred_language($account), array('account' => $user, 'token' => $token) ); |
| 404 |
|
|
| 405 |
drupal_set_message(t('We have created the token @token for you. We will also email you your token. You are free to start uploading.', |
drupal_set_message( |
| 406 |
array('@token' => $token)) |
t('We have created the token @token for you. We will also email you your token. You are free to start uploading.', |
| 407 |
|
array('@token' => $token) ) |
| 408 |
); |
); |
|
|
|
| 409 |
return; |
return; |
| 410 |
} |
} |
| 411 |
|
|
| 412 |
|
/** |
| 413 |
|
* Outbound mail functions |
| 414 |
|
* |
| 415 |
|
* @param unknown_type $key |
| 416 |
|
* @param unknown_type $message |
| 417 |
|
* @param unknown_type $params |
| 418 |
|
*/ |
| 419 |
|
function media_mover_ftp_mail($key, &$message, $params) { |
| 420 |
|
// create the body |
| 421 |
|
// @TODO implement real token replacement |
| 422 |
|
$body = variable_get('mm_ftp_email_text', t('Your token is: [token]')); |
| 423 |
|
$search = array('[token]', '[user name]', '[site name]', '[site url]'); |
| 424 |
|
$replace = array($params['token'], $user->name, variable_get('site_name', '' ), url('', array('absolute' => true) )); |
| 425 |
|
$body = str_replace($search, $replace, $body); |
| 426 |
|
|
| 427 |
|
if ($key == 'ftp_token') { |
| 428 |
|
$message['subject'] = t('[!sitename] Your FTP token', array('!sitename' => variable_get('site_name', 'Drupal'))); |
| 429 |
|
$message['body'] = $body; |
| 430 |
|
} |
| 431 |
|
} |
| 432 |
|
|
| 433 |
|
|
| 434 |
/** |
/** |
| 435 |
* Implementation of hook_token_values(). |
* Implementation of hook_token_values(). |