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

Diff of /contributions/modules/urllist/urllist.module

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

revision 1.16, Tue Jan 13 05:08:06 2009 UTC revision 1.17, Thu Mar 5 01:55:35 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: urllist.module,v 1.15 2008/02/15 16:16:25 deekayen Exp $  // $Id: urllist.module,v 1.16 2009/01/13 05:08:06 deekayen Exp $
3    
4  /**  /**
5   * @file   * @file
6   * Creates a list of URLs for search engines to index.   * Creates a list of URLs for search engines to index.
7   *   *
8   * @version $Id: urllist.module,v 1.15 2008/02/15 16:16:25 deekayen Exp $   * @version $Id: urllist.module,v 1.16 2009/01/13 05:08:06 deekayen Exp $
9   * @author David Kent Norman   * @author David Kent Norman
10   * @link http://deekayen.net/   * @link http://deekayen.net/
11   */   */
# Line 67  function urllist_menu() { Line 67  function urllist_menu() {
67  function urllist_admin_settings() {  function urllist_admin_settings() {
68    $form = array();    $form = array();
69    $form['urllist_logacc'] = array(    $form['urllist_logacc'] = array(
70      '#type'          => 'checkbox',      '#type' => 'checkbox',
71      '#title'         => 'Log accesses',      '#title' => 'Log accesses',
72      '#default_value' => variable_get('urllist_logacc', 0),      '#default_value' => variable_get('urllist_logacc', 0),
73      '#description'   => t('If enabled, a watchdog entry will be made each time the URL list is accessed, containing information about the requestor.')      '#description' => t('If enabled, a watchdog entry will be made each time the URL list is accessed, containing information about the requestor.')
74    );    );
   
75    $form['url_submit_yahoo'] = array(    $form['url_submit_yahoo'] = array(
76      '#type' => 'fieldset',      '#type' => 'fieldset',
77      '#title' => t('Yahoo! Update Notification API'),      '#title' => t('Yahoo! Update Notification API'),
# Line 107  function urllist_admin_settings() { Line 106  function urllist_admin_settings() {
106      '#return value' => '',      '#return value' => '',
107      '#default_value' => variable_get('urllist_yahoo_appid', '')      '#default_value' => variable_get('urllist_yahoo_appid', '')
108    );    );
   
109    $form['auth'] = array(    $form['auth'] = array(
110      '#type' => 'fieldset',      '#type' => 'fieldset',
111      '#title' => t('Yahoo! Site Explorer Authentication'),      '#title' => t('Yahoo! Site Explorer Authentication'),
# Line 153  function urllist_admin_settings_submit() Line 151  function urllist_admin_settings_submit()
151  }  }
152    
153  /**  /**
154   * Implmentation of hook_nodeapi().   * Implmentation of hook_nodeapi_insert().
155   */   */
156  function urllist_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {  function urllist_nodeapi_insert(&$node, $teaser = NULL, $page = NULL) {
157    switch ($op) {    if (variable_get('urllist_yahoo_submit', 0) && $node->status) {
158      case 'insert':      watchdog('urllist', "Submitting URL list to Yahoo! because node %node_id was inserted or deleted.", array('%node_id' => $node->nid), WATCHDOG_DEBUG);
159      case 'delete':      _urllist_submit_yahoo();
160        if (variable_get('urllist_yahoo_submit', 0) && $node->status) {    }
161          watchdog('urllist', "Submitting URL list to Yahoo! because node %node_id was inserted or deleted.", array('%node_id' => $node->nid), WATCHDOG_DEBUG);  }
162          _urllist_submit_yahoo();  
163        }  /**
164        break;   * Implmentation of hook_nodeapi_delete().
165      case 'update':   */
166        if (variable_get('urllist_yahoo_submit', 0) && ($node->status || $oldnode->status)) {  function urllist_nodeapi_delete(&$node, $teaser = NULL, $page = NULL) {
167          watchdog('urllist', "Submitting URL list to Yahoo! because node %node_id was updated.", array('%node_id' => $node->nid), WATCHDOG_DEBUG);    urllist_nodeapi_insert($node, $teaser, $page);
168          _urllist_submit_yahoo();  }
169        }  
170        break;  /**
171     * Implmentation of hook_nodeapi_update().
172     */
173    function urllist_nodeapi_update(&$node, $teaser = NULL, $page = NULL) {
174      if (variable_get('urllist_yahoo_submit', 0) && ($node->status || $oldnode->status)) {
175        watchdog('urllist', "Submitting URL list to Yahoo! because node %node_id was updated.", array('%node_id' => $node->nid), WATCHDOG_DEBUG);
176        _urllist_submit_yahoo();
177    }    }
178  }  }
179    
# Line 188  function theme_urllist() { Line 192  function theme_urllist() {
192      set_time_limit(240);      set_time_limit(240);
193    }    }
194    header('Content-type: text/plain');    header('Content-type: text/plain');
195    print url('', array('absolute' => TRUE)) ."\n";    print url('', array('absolute' => TRUE)) . "\n";
196    $result = db_query("SELECT n.nid, n.type, n.status, n.promote, n.changed, u.dst FROM {node} n LEFT JOIN {url_alias} u ON u.src=CONCAT('node/',CAST(n.nid as CHAR))");    $result = db_query("SELECT n.nid, n.type, n.status, n.promote, n.changed, u.dst FROM {node} n LEFT JOIN {url_alias} u ON u.src=CONCAT('node/',CAST(n.nid as CHAR))");
197    while ($node = db_fetch_object($result)) {    while ($node = $result->fetchObject()) {
198      if ($node->status) { // add check for if the node type is disabled or not      if ($node->status) { // add check for if the node type is disabled or not
199        if (isset($node->dst)) { // alias is named        if (isset($node->dst)) { // alias is named
200          print url($node->dst, array('absolute' => TRUE)) ."\n";          print url($node->dst, array('absolute' => TRUE)) . "\n";
201        }        }
202        else {        else {
203          print url('node/'. $node->nid, array('absolute' => TRUE)) ."\n";          print url('node/' . $node->nid, array('absolute' => TRUE)) . "\n";
204        }        }
205      }      }
206    }    }
207    if (module_exists('taxonomy')) {    if (module_exists('taxonomy')) {
208      $result = db_query('SELECT d.tid FROM {term_data} d');      $result = db_query('SELECT d.tid FROM {taxonomy_term_data} d');
209      while ($topic = db_fetch_object($result)) {      while ($topic = $result->fetchObject()) {
210        print url('taxonomy/term/'. $topic->tid, array('absolute' => TRUE)) ."\n";        print url('taxonomy/term/' . $topic->tid, array('absolute' => TRUE)) . "\n";
211      }      }
212    }    }
213    if (module_exists('search')) {    if (module_exists('search')) {
214      print url('search', array('absolute' => TRUE)) ."\n";      print url('search', array('absolute' => TRUE)) . "\n";
215    }    }
216    if (module_exists('image')) {    if (module_exists('image')) {
217      print url('image', array('absolute' => TRUE)) ."\n";      print url('image', array('absolute' => TRUE)) . "\n";
218    }    }
219    if (module_exists('randomizer')) {    if (module_exists('randomizer')) {
220      print url('randomizer', array('absolute' => TRUE)) ."\n";      print url('randomizer', array('absolute' => TRUE)) . "\n";
221    }    }
222    if (module_exists('blog')) {    if (module_exists('blog')) {
223      print url('blog', array('absolute' => TRUE)) ."\n";      print url('blog', array('absolute' => TRUE)) . "\n";
224    }    }
225    if (variable_get('urllist_logacc', 0)) {    if (variable_get('urllist_logacc', 0)) {
226      watchdog('urllist', 'URL list downloaded by '. getenv('HTTP_USER_AGENT') .' at '. getenv('REMOTE_ADDR') .'.', NULL, WATCHDOG_INFO);      watchdog('urllist', 'URL list downloaded by ' . getenv('HTTP_USER_AGENT') . ' at ' . getenv('REMOTE_ADDR') . '.', NULL, WATCHDOG_INFO);
227    }    }
228  }  }
229    
# Line 238  function urllist_verify_yahoo() { Line 242  function urllist_verify_yahoo() {
242   * @link https://developer.yahoo.com/wsregapp/index.php?view   * @link https://developer.yahoo.com/wsregapp/index.php?view
243   */   */
244  function _urllist_submit_yahoo() {  function _urllist_submit_yahoo() {
245    $result = drupal_http_request('http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid='. variable_get('urllist_yahoo_appid', '') .'&url='. url('urllist.txt', array('absolute' => TRUE)));    $result = drupal_http_request('http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=' . variable_get('urllist_yahoo_appid', '') . '&url=' . url('urllist.txt', array('absolute' => TRUE)));
246    if ($result->code == 200) {    if ($result->code == 200) {
247      watchdog('urllist', 'URL list successfully submitted to Yahoo!', NULL, WATCHDOG_INFO);      watchdog('urllist', 'URL list successfully submitted to Yahoo!', NULL, WATCHDOG_INFO);
248    }    }
# Line 246  function _urllist_submit_yahoo() { Line 250  function _urllist_submit_yahoo() {
250      watchdog('urllist', 'Error occurred submitting URL list to Yahoo!: @code: @data', array('@code' => $result->code, '@data' => $result->data), WATCHDOG_ERROR);      watchdog('urllist', 'Error occurred submitting URL list to Yahoo!: @code: @data', array('@code' => $result->code, '@data' => $result->data), WATCHDOG_ERROR);
251    }    }
252    if (variable_get('urllist_yahoo_rss_submit', 0)) {    if (variable_get('urllist_yahoo_rss_submit', 0)) {
253      $result = drupal_http_request('http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid='. variable_get('urllist_yahoo_appid', '') .'&url='. url('rss.xml', array('absolute' => TRUE)));      $result = drupal_http_request('http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=' . variable_get('urllist_yahoo_appid', '') . '&url=' . url('rss.xml', array('absolute' => TRUE)));
254      if ($result->code == 200) {      if ($result->code == 200) {
255        watchdog('urllist', 'RSS feed successfully submitted to Yahoo!.', NULL, WATCHDOG_INFO);        watchdog('urllist', 'RSS feed successfully submitted to Yahoo!.', NULL, WATCHDOG_INFO);
256      }      }

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.2