/[drupal]/contributions/modules/jaiku/jaiku_user.module
ViewVC logotype

Contents of /contributions/modules/jaiku/jaiku_user.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Jan 3 18:06:37 2008 UTC (22 months, 3 weeks ago) by tomsun
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-php
Moved user API key handling and node crossposting to separate modules.
1 <?php
2 // $Id: $
3
4 /**
5 * Implementation of hook_user()
6 */
7 function jaiku_user_user($op, &$edit, &$account, $category = NULL) {
8 switch ($op) {
9 case 'categories':
10 return array(array('name' => 'Notification options', 'title' => 'Notification options', 'weight' => 3));
11
12 case 'form':
13 if (($category == 'Notification options')) {
14 $form['jaiku'] = array(
15 '#type' => 'fieldset',
16 '#weight' => 4,
17 '#title' => t('Jaiku settings'));
18 $form['jaiku']['jaiku_user'] = array(
19 '#type' => 'textfield',
20 '#title' => t('Username'),
21 '#default_value' => $edit['jaiku_user'],
22 '#description' => t('The username (email address) associated with your jaiku.com account'));
23 $form['jaiku']['jaiku_key'] = array(
24 '#type' => 'textfield',
25 '#title' => t('Your Jaiku API key'),
26 '#default_value' => $edit['jaiku_key'],
27 '#description' => 'Your personal key - find it by going to <a target="_new" href="http://jaiku.com/login?redirect_to=http://api.jaiku.com/">http://api.jaiku.com</a>',
28 );
29
30 $form['jaiku']['jaiku_format'] = array(
31 '#type' => 'textfield',
32 '#title' => t('Text format'),
33 '#default_value' => $edit['jaiku_format'],
34 '#description' => t('Format of the text to submit. Use !title and !url for the post title and url respectively.'));
35
36 return $form;
37 }
38
39 }
40 }
41
42
43 /**
44 * Post a jaiku as the selected user, using the jaiku api module.
45 */
46 function jaiku_user_post($message, $args = array(), $drupal_username = '') {
47 if (empty($drupal_username)) {
48 // Use current user.
49 global $user;
50 $drupal_username = $user->name;
51 }
52
53 $account = user_load(array('name' => $drupal_username));
54 if (empty($account->jaiku_user)) {
55 return false;
56 }
57 if (empty($account->jaiku_key)) {
58 return false;
59 }
60
61 return jaiku_post($account->jaiku_user, $account->jaiku_key, $message, $args);
62 }
63
64
65 function jaiku_user_get_stream($drupal_username = '') {
66 if (empty($drupal_username)) {
67 // Use current user.
68 global $user;
69 $drupal_username = $user->name;
70 }
71
72 $account = user_load(array('name' => $drupal_username));
73 if (empty($account->jaiku_user)) {
74 return false;
75 }
76
77 return jaiku_get_stream($account->jaiku_user);
78 }
79
80
81 function jaiku_user_get_presence($drupal_username = '') {
82 if (empty($drupal_username)) {
83 // Use current user.
84 global $user;
85 $drupal_username = $user->name;
86 }
87
88 $account = user_load(array('name' => $drupal_username));
89 if (empty($account->jaiku_user)) {
90 return false;
91 }
92
93 return jaiku_get_presence($account->jaiku_user);
94 }
95
96
97
98 function jaiku_user_get_user($drupal_username = '') {
99 if (empty($drupal_username)) {
100 // Use current user.
101 global $user;
102 $drupal_username = $user->name;
103 }
104
105 $account = user_load(array('name' => $drupal_username));
106 if (empty($account->jaiku_user)) {
107 return false;
108 }
109
110 return jaiku_get_user($account->jaiku_user);
111 }

  ViewVC Help
Powered by ViewVC 1.1.2