You are here

function themekey_ui_user in ThemeKey 6.3

Same name and namespace in other branches
  1. 6.4 themekey_ui.module \themekey_ui_user()
  2. 6.2 themekey_ui.module \themekey_ui_user()

Implements hook_user()

File

./themekey_ui.module, line 270
ThemeKey UI is an extension for ThemeKey

Code

function themekey_ui_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'insert':
    case 'update':
      if (user_access('assign theme to own nodes') && variable_get('themekey_ui_author', 0) && !empty($edit['themekey_ui_theme'])) {
        $author_theme = array(
          'uid' => $account->uid,
          'theme' => $edit['themekey_ui_theme'],
        );
        if (db_result(db_query("SELECT 1 FROM {themekey_ui_author_theme} WHERE uid = %d", $account->uid))) {
          drupal_write_record('themekey_ui_author_theme', $author_theme, array(
            'uid',
          ));
        }
        else {
          drupal_write_record('themekey_ui_author_theme', $author_theme);
        }
        if ($edit['themekey_ui_theme'] != $account->themekey_ui_theme) {

          // theme settings changed
          // fast deletion of page cache (truncate)
          cache_clear_all('*', 'cache_page', TRUE);
        }
        $edit['themekey_ui_theme'] = NULL;
      }
      break;
    case 'delete':
      db_query("DELETE FROM {themekey_ui_author_theme} WHERE uid = %d", $account->uid);
      break;
  }
}