/[drupal]/contributions/modules/subscription/CONTRIBUTE.txt
ViewVC logotype

Diff of /contributions/modules/subscription/CONTRIBUTE.txt

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

revision 1.2, Mon Dec 5 13:55:44 2005 UTC revision 1.3, Tue Dec 20 12:38:07 2005 UTC
# Line 1  Line 1 
1    
2  Contribute  Contribute
3  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
4  1. How to register subscription about own content type?  1. How do you register subscription about a new content type?
5    
6  Create a new module function, which invoke subscription_store.  Create a new module function, which invokes subscription_store.
7    
8  Example:  Example:
9  <code>  <code>
# Line 15  function watchdognotify_subscribe(){ Line 15  function watchdognotify_subscribe(){
15  }  }
16  </code>  </code>
17    
18  Display link to new function via hook_subscription  Use hook_subscription to display a link to your new subscription type.
19  <code>  <code>
20  function watchdognotify_subscription($op, $arg1 = null, $arg2 = null) {  function watchdognotify_subscription($op, $arg1 = null, $arg2 = null) {
21    if ($op == 'special') {    if ($op == 'special') {
# Line 24  function watchdognotify_subscription($op Line 24  function watchdognotify_subscription($op
24  }  }
25  </code>  </code>
26    
27  2. How to notify users about new contents?  2. How do you notify users about new content?
28    
29  a.) call subscription_trigger when the new content created  A.) call subscription_trigger when the new content is created
30    
31  OR  OR
32    
33  b.) check frequently new contents via hook_subscription() with cron op:  B.) check frequently for new content via hook_subscription() with cron op:
34    
35  Example:  Example:
36  <code>  <code>
# Line 46  function watchdognotify_subscription($op Line 46  function watchdognotify_subscription($op
46  }  }
47  </code>  </code>
48    
49  If necessary you can return more than one type of contents:  If necessary you can return more than one type of content:
50    <code>
51  return array(array('watchdog'=>array(...),'error'=>array(....)))  return array(array('watchdog'=>array(...),'error'=>array(....)))
52    </code>
53    
54    If it is possible to implement both methods A and B from above, implement both, and choose which one to use:
55    
56  If both a and b methods are implementable, please implement both and choose a.) when  Use method A when
57  !variable_get('subscription_instant_mode', 0) and b.) when it is true.  <code>
58    if (variable_get('subscription_instant_mode', 0)) {
59      // use method B
60    }
61    else {
62      // use method A
63    }
64    </code>
65    
66  3. How will the content be displayed in existing channels?  3. How will the content be displayed in existing channels?
67    
68  Register an own formatter via hook_subscription():  Register a formatter via hook_subscription():
69    
70  <code>  <code>
71  function watchdognotify_subscription($op, $arg1 = null, $arg2 = null) {  function watchdognotify_subscription($op, $arg1 = null, $arg2 = null) {
# Line 67  function watchdognotify_subscription($op Line 78  function watchdognotify_subscription($op
78  }  }
79  </code>  </code>
80    
81  Then implement handler:  Then implement a handler:
82  <code>  <code>
83  function watchdognotify_formatter($object, $type) {  function watchdognotify_formatter($object, $type) {
84   return wordwrap('['.format_date($object['timestamp'], 'small').']['.$object['hostname'].']ERROR: '. $object['message']."\n",72);   return wordwrap('['.format_date($object['timestamp'], 'small').']['.$object['hostname'].']ERROR: '. $object['message']."\n",72);
# Line 75  function watchdognotify_formatter($objec Line 86  function watchdognotify_formatter($objec
86  </code>  </code>
87    
88    
89  4. How to create own channels?  4. How do you create new channels?
90  Register the channel via hook_subscriptions:  Register the channel via hook_subscriptions:
91  <code>  <code>
92  function ftpchannel_subscription($op, $arg1 = null, $arg2 = null) {  function ftpchannel_subscription($op, $arg1 = null, $arg2 = null) {

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2