You are here

function asset_youtube_user in Asset 6

Same name and namespace in other branches
  1. 5 asset_youtube/asset_youtube.module \asset_youtube_user()
1 call to asset_youtube_user()
asset_youtube_asset_type in asset_youtube/asset_youtube.module

File

asset_youtube/asset_youtube.module, line 297

Code

function asset_youtube_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'categories':
      return array(
        array(
          'name' => 'asset',
          'title' => t('Asset'),
          'weight' => 1,
        ),
      );
      break;
    case 'form':
      if ($category == 'asset') {
        $form['asset_youtube'] = array(
          '#type' => 'fieldset',
          '#title' => t('YouTube Settings'),
          '#tree' => true,
        );
        $form['asset_youtube']['username'] = array(
          '#type' => 'textfield',
          '#title' => t('YouTube User Name'),
          '#default_value' => $account->asset_youtube['username'],
        );
      }
      return $form;
    case 'update':
      if ($edit['asset_youtube']['username']) {
        if (db_result(db_query("SELECT COUNT(*) FROM {asset_youtube_user} WHERE uid=%d", $account->uid))) {
          db_query("UPDATE {asset_youtube_user} SET username='%s' WHERE uid=%d", $edit['asset_youtube']['username'], $account->uid);
          break;
        }
      }
      else {
        break;
      }

    // fall through
    case 'insert':
      if ($edit['asset_youtube']['username']) {
        db_query("INSERT INTO {asset_youtube_user} (uid, username) VALUES (%d, '%s')", $account->uid, $edit['asset_youtube']['username']);
      }
      break;
    case 'delete':
      db_query('DELETE FROM {asset_youtube_user} WHERE uid = %d', $account->uid);
      break;
    case 'load':
      $account->asset_youtube = db_fetch_array(db_query('SELECT username FROM {asset_youtube_user} WHERE uid=%d', $account->uid));
      break;
  }
}