/[drupal]/contributions/modules/subscription/subscription.module
ViewVC logotype

Diff of /contributions/modules/subscription/subscription.module

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

revision 1.14, Tue Apr 4 19:29:32 2006 UTC revision 1.15, Thu Apr 6 14:51:18 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /* $Id: subscription.module,v 1.13 2006/04/04 18:23:01 ee Exp $ */  /* $Id: subscription.module,v 1.14 2006/04/04 19:29:32 ee Exp $ */
3    
4  function subscription_help($section) {  function subscription_help($section) {
5    switch ($section) {    switch ($section) {
# Line 290  function subscription_cron() { Line 290  function subscription_cron() {
290  function subscription_get_all($digest = false) {  function subscription_get_all($digest = false) {
291    $rules = array();    $rules = array();
292    $digest = ($digest ? 1 : 0);    $digest = ($digest ? 1 : 0);
293    $result = db_query("SELECT s.*,c.name,c.id FROM {subscription_subscriptions} s LEFT JOIN {subscription_channels} c ON s.cid=c.cid WHERE c.daily=%d ORDER BY uid, cid, object, condition", $digest);    $result = db_query("SELECT s.*,c.name,c.id FROM {subscription_subscriptions} s LEFT JOIN {subscription_channels} c ON s.cid=c.cid WHERE c.daily=%d ORDER BY uid, cid, object, `condition`", $digest);
294    while ($rule = db_fetch_array($result)) {    while ($rule = db_fetch_array($result)) {
295      $rules[] = $rule;      $rules[] = $rule;
296    }    }
# Line 336  function subscription_get_channelhandler Line 336  function subscription_get_channelhandler
336  function subscription_get() {  function subscription_get() {
337    global $user;    global $user;
338    $rules = array();    $rules = array();
339    $result = db_query("SELECT s.*,c.name,c.id FROM {subscription_subscriptions} s LEFT JOIN {subscription_channels} c ON  s.cid=c.cid WHERE s.uid = %d ORDER BY uid, cid, object, condition", $user->uid);    $result = db_query("SELECT s.*,c.name,c.id FROM {subscription_subscriptions} s LEFT JOIN {subscription_channels} c ON  s.cid=c.cid WHERE s.uid = %d ORDER BY uid, cid, object, `condition`", $user->uid);
340    while ($rule = db_fetch_array($result)) {    while ($rule = db_fetch_array($result)) {
341      $rules[] = $rule;      $rules[] = $rule;
342    }    }
# Line 417  function subscription_store($type, $cond Line 417  function subscription_store($type, $cond
417      return null;      return null;
418    }    }
419    $condition = serialize($condition);    $condition = serialize($condition);
420    $sid = db_next_id("subscribe_subscription", "sid");    $sid = db_next_id('subscribe_subscription', 'sid');
421    db_query("INSERT INTO {subscription_subscriptions} (sid,uid,object,condition,cid) VALUES (%d,%d,'%s','%s',%d)", $sid, $user->uid, $type, $condition, $channel);    db_query("INSERT INTO {subscription_subscriptions} (sid,uid,object,`condition`,cid) VALUES (%d,%d,'%s','%s',%d)", $sid, $user->uid, $type, $condition, $channel);
422    return $sid;    return $sid;
423   }   }
424   /**   /**
# Line 427  function subscription_store($type, $cond Line 427  function subscription_store($type, $cond
427  function subscription_is_subscribed($type, $condition) {  function subscription_is_subscribed($type, $condition) {
428    global $user;    global $user;
429    $condition = serialize($condition);    $condition = serialize($condition);
430    $sid = db_next_id("subscribe_subscription", "sid");    $sid = db_next_id('subscribe_subscription', 'sid');
431    $result = db_query("SELECT * FROM {subscription_subscriptions} WHERE uid=%d AND object='%s' AND condition='%s' AND cid=%d", $user->uid, $type, $condition, subscription_get_default_channel());    $result = db_query("SELECT * FROM {subscription_subscriptions} WHERE uid=%d AND object='%s' AND `condition`='%s' AND cid=%d", $user->uid, $type, $condition, subscription_get_default_channel());
432    $role = db_fetch_array($result);    $role = db_fetch_array($result);
433    return $role;    return $role;
434   }   }
# Line 438  function subscription_is_subscribed($typ Line 438  function subscription_is_subscribed($typ
438   */   */
439  function subscription_subscribe() {  function subscription_subscribe() {
440      global $user;      global $user;
441       if (arg(2) == "comment") {       if (arg(2) == 'comment') {
442        if (arg(3) == null) {        if (arg(3) == null) {
443          $condition = array();          $condition = array();
444        }        }
# Line 447  function subscription_subscribe() { Line 447  function subscription_subscribe() {
447        }        }
448        $type = arg(2);        $type = arg(2);
449      }      }
450      else if (arg(2) == "user") {      else if (arg(2) == 'user') {
451        if (arg(3) == 'all') {        if (arg(3) == 'all') {
452          $condition = array('uid' => arg(4));          $condition = array('uid' => arg(4));
453          $type = "*";          $type = '*';
454        }        }
455        else {        else {
456          $condition = array('parent_uid' => arg(4));          $condition = array('parent_uid' => arg(4));
457          $type = "comment";          $type = 'comment';
458        }        }
459      }      }
460      else if (arg(2) == "node") {      else if (arg(2) == 'node') {
461        $condition = array('type' => arg(3));        $condition = array('type' => arg(3));
462        $type = "node";        $type = 'node';
463      }      }
464      else if (arg(2) == "taxonomy") {      else if (arg(2) == 'taxonomy') {
465        if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', arg(3))) {        if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', arg(3))) {
466          $tids = preg_split('/[+ ]/', arg(3));          $tids = preg_split('/[+ ]/', arg(3));
467          $type = "node";          $type = "node";
# Line 568  function subscription_list() { Line 568  function subscription_list() {
568      $merge_ids = array();      $merge_ids = array();
569      foreach ($edit as $key => $value) {      foreach ($edit as $key => $value) {
570        if ($value == 1) {        if ($value == 1) {
571          $merge_ids[] = str_replace("merge", "", $key);          $merge_ids[] = str_replace('merge', '', $key);
572        }        }
573      }      }
574    
# Line 597  function subscription_list() { Line 597  function subscription_list() {
597        }        }
598      }      }
599      if (!form_get_errors()) {      if (!form_get_errors()) {
600        $sid = db_next_id("subscribe_subscription", "sid");        $sid = db_next_id('subscribe_subscription', 'sid');
601        db_query("INSERT INTO {subscription_subscriptions} (sid,uid,object,condition,cid) VALUES (%d,%d,'%s','%s',%d)", $sid, $user->uid, $main_type, serialize($condition), $channel);        db_query("INSERT INTO {subscription_subscriptions} (sid,uid,object,`condition`,cid) VALUES (%d,%d,'%s','%s',%d)", $sid, $user->uid, $main_type, serialize($condition), $channel);
602        foreach ($merge_ids as $role_id) {        foreach ($merge_ids as $role_id) {
603          db_query("DELETE FROM {subscription_subscriptions} WHERE sid=%d", $role_id);          db_query("DELETE FROM {subscription_subscriptions} WHERE sid=%d", $role_id);
604        }        }
# Line 614  function subscription_list() { Line 614  function subscription_list() {
614      }      }
615      // new form api sucks      // new form api sucks
616      $form = "<form method=\"post\" >";      $form = "<form method=\"post\" >";
617      $form .= theme("table", array(t("Object"), t("Condition"), t("Channel"), t("Function"), t("Merge")), $table);      $form .= theme('table', array(t('Object'), t('Condition'), t('Channel'), t('Function'), t('Merge')), $table);
618      $form .= '<input type="submit" value="Merge">';      $form .= '<input type="submit" value="Merge">';
619      $form .= "</form>";      $form .= "</form>";
620      $page .= $form;      $page .= $form;
# Line 622  function subscription_list() { Line 622  function subscription_list() {
622    else {    else {
623      $page .= t("Currently there are no subscriptions.");      $page .= t("Currently there are no subscriptions.");
624    }    }
625    $page .= "<p>".t("There is an OR relationship between the lines. If you would like to use" .    $page .= '<p>'.t("There is an OR relationship between the lines. If you would like to use" .
626             " AND relationships, use the 'Merge' button.")."</p> ";             " AND relationships, use the 'Merge' button.")."</p> ";
627    $page .= "<p>".t("Depending on the channel used, you may receive one message per channel with all events.")."</p>";    $page .= '<p>'.t("Depending on the channel used, you may receive one message per channel with all events.")."</p>";
628    $page .= "<p>".t("You can change the subscription target channel from your ").l(t("subscription management page"),'user/'.$user->uid.'/subscriptions')."</p>";    $page .= '<p>'.t("You can change the subscription target channel from your ").l(t("subscription management page"),'user/'.$user->uid.'/subscriptions')."</p>";
629    $page .= "<h1>". t("Available special subscriptions") ."</h1>";    $page .= '<h1>'. t("Available special subscriptions") ."</h1>";
630    $page .= theme('item_list', module_invoke_all('subscription', 'special'));    $page .= theme('item_list', module_invoke_all('subscription', 'special'));
631    
632    return $page;    return $page;
# Line 664  function subscription_simpleformatter($o Line 664  function subscription_simpleformatter($o
664    if (is_object($object)) {    if (is_object($object)) {
665      $object = get_object_vars($object);      $object = get_object_vars($object);
666    }    }
667    $dump = "";    $dump = '';
668    if ($type == "node") {    if ($type == 'node') {
669      $dump .= "== ". $object['title'] ." ==\n\n";      $dump .= '== '. $object['title'] ." ==\n\n";
670      $dump .= wordwrap($object['body'], 72) ."\n\n";      $dump .= wordwrap($object['body'], 72) ."\n\n";
671      $dump .= "(". $object['name'] ." -- ". $object['date'] .")\n";      $dump .= '('. $object['name'] .' -- '. $object['date'] .")\n";
672      $dump .= "url: ". url("node/". $object['nid'], NULL, NULL, true) ."\n";      $dump .= 'url: '. url("node/". $object['nid'], NULL, NULL, true) ."\n";
673      return $dump;      return $dump;
674    }    }
675    else if ($type == "comment") {    else if ($type == 'comment') {
676      $dump .= "== ". $object['subject'] ." ==\n\n";      $dump .= '== '. $object['subject'] ." ==\n\n";
677      $dump .= wordwrap($object['comment'], 72) ."\n\n";      $dump .= wordwrap($object['comment'], 72) ."\n\n";
678      $dump .= "(". $object['name'] ." -- ". $object['date'] .")\n";      $dump .= '('. $object['name'] ." -- ". $object['date'] .")\n";
679      $dump .= "url: ". url("node/". $object['nid'], NULL, NULL, true) ."\n";      $dump .= 'url: '. url("node/". $object['nid'], NULL, NULL, true) ."\n";
680      return $dump;      return $dump;
681    }    }
682    else {    else {
# Line 693  function subscription_format($object, $t Line 693  function subscription_format($object, $t
693   */   */
694  function subscription_simpleformat($objects, $channel) {  function subscription_simpleformat($objects, $channel) {
695      $global_header =      $global_header =
696        t("There is new content:") ."\n\n".        t('There is new content:') ."\n\n";
       "";  
697      $group_header =      $group_header =
698        "========================================================================\n".        "========================================================================\n".
699        " ". t("New") ." %type%\n".        " ". t("New") ." %type%\n".

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.2