public function application_manager::create_application in Apply for role 8
Create an application.
Parameters
int $uid:
array $rids:
File
- src/
application_manager.php, line 98 - Contains two classes.
Class
- application_manager
- Application manager object used for performing any tasks relating to applications.
Namespace
Drupal\apply_for_roleCode
public function create_application($uid, $rids, $message = NULL) {
Database::getConnection()
->insert('apply_for_role_applications')
->fields(array(
'uid',
'rids',
'created',
'message',
))
->values(array(
$uid,
Serialization\Json::encode($rids),
time(),
$message,
))
->execute();
// Email admin on approval.
if ($this->apply_for_role_config
->get('send_user_approval_email')) {
if ($this->apply_for_role_config
->get('admin_email_addresses')) {
$to = $this->apply_for_role_config
->get('admin_email_addresses');
}
else {
// No users specificed, send to superadmin.
// @TODO: Replace deprecated user_load function.
$to = user_load(1)
->getEmail();
}
$subject = $this->apply_for_role_config
->get('admin_email_subject');
$body = $this->apply_for_role_config
->get('admin_email_body');
$replacements = array(
'%URL' => \Drupal::request()
->getHost(),
'%ROLE' => $this
->rids_to_text($rids),
);
$this
->send_email($to, $subject, $body, $replacements);
}
}