You are here

function blogapi_validate_user in Blog API 7

Same name and namespace in other branches
  1. 7.2 blogapi.module \blogapi_validate_user()

Ensure that the given user has permission to edit a blog.

12 calls to blogapi_validate_user()
blogapi_blogger_delete_post in ./blogapi.module
Blogging API callback. Removes the specified blog node.
blogapi_blogger_edit_post in ./blogapi.module
Blogging API callback. Modifies the specified blog node.
blogapi_blogger_get_post in ./blogapi.module
Blogging API callback. Returns a specified blog node.
blogapi_blogger_get_recent_posts in ./blogapi.module
Blogging API callback. Returns the latest few postings in a user's blog. $bodies TRUE <a href="http://movabletype.org/docs/mtmanual_programmatic.html#item_mt%2EgetRece... returns a bandwidth-friendly list</a>.
blogapi_blogger_get_users_blogs in ./blogapi.module
Blogging API callback. Finds the URL of a user's blog.

... See full list

File

./blogapi.module, line 732
Enable users to post using applications that support XML-RPC blog APIs.

Code

function blogapi_validate_user($username, $password) {
  global $user;

  // is the username and password valid?
  $tmpuid = user_authenticate($username, $password);
  if ($tmpuid !== FALSE) {

    // user/pw OK, check access to blog
    $tmpuser = user_load_by_name($username);
    if (user_access('administer content with blog api', $tmpuser)) {
      $user = $tmpuser;
      return $user;
    }
    else {
      return t('You do not have permission to edit this blog.');
    }
  }
  else {
    return t('Wrong username or password.');
  }
}