/**
  * Given the Mambo username, password, and download key attempt to authenticate, if
  * successful then store these credentials
  *
  * @param username      Mambo username
  * @param password      Mambo password
  * @param systemname   the user's download key
  * @return              true if successful, false otherwise
  */
 function authenticate($username, $password, $systemname = '', $terms_checked = true)
 {
     PackageManager::setCredentials($username, $password, $systemname);
     PackageManagerComm::clearSession();
     $result = PackageManagerComm::login($terms_checked);
     if (is_array($result)) {
         return $result;
     } else {
         return true;
     }
 }