function drush_tripal_set_user

3.x tripal.drush.inc drush_tripal_set_user($username)

Set the user to run a drush job.

Related topics

7 calls to drush_tripal_set_user()
drush_tripal_chado_trp_import_pubs in tripal_chado/tripal_chado.drush.inc
Imports publications into Chado
drush_tripal_core_set_user in legacy/tripal_core/tripal_core.drush.inc
Set the user to run a drush job.
drush_tripal_trp_prepare_chado in tripal/tripal.drush.inc
Prepares content types on the site after chado installation.
drush_tripal_trp_rerun_job in tripal/tripal.drush.inc
Executes jobs in the Tripal Jobs Queue.
drush_tripal_trp_run_jobs in tripal/tripal.drush.inc
Executes jobs in the Tripal Jobs Queue.

... See full list

File

tripal/tripal.drush.inc, line 136
Contains function relating to drush-integration of this module.

Code

function drush_tripal_set_user($username) {
  if ($username) {
    $sql = "SELECT uid FROM {users} WHERE name = :name";
    $results = db_query($sql, array(':name' => $username));
    $u = $results->fetchObject();
    if (!$u) {
      drush_print(date('Y-m-d H:i:s'));
      drush_print('ERROR: Please provide a valid username (--username argument) for running this job.');
      exit;
    }
    global $user;
    $user = user_load($u->uid);
    return $u->uid;
  }
  else {
    drush_print(date('Y-m-d H:i:s'));
    drush_print('ERROR: Please provide a username (--username argument) for running this job.');
    exit;
  }
}