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

Diff of /contributions/modules/advogato_import/advogato_import.module

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

revision 1.3, Fri Mar 17 20:50:50 2006 UTC revision 1.4, Sat Mar 18 08:41:07 2006 UTC
# Line 3  Line 3 
3    
4  /**  /**
5   * @file   * @file
6   * Imports diary entries to Drupal 4.6.3 from Advogato.org XMLRPC   * Imports diary entries to Drupal 4.7 from Advogato.org XMLRPC
7   *   *
8   * @author David Kent Norman <deekayen at: deekayen (dot) net>   * @author David Kent Norman <deekayen at: deekayen (dot) net>
9   * @link http://deekayen.net/   * @link http://deekayen.net/
# Line 16  Line 16 
16   * @code   * @code
17    
18  CREATE TABLE advogato_import (  CREATE TABLE advogato_import (
19    qid int(10) unsigned NOT NULL,    qid int(10) unsigned NOT NULL auto_increment,
20    uid int(10) unsigned NOT NULL default '0',    uid int(10) unsigned NOT NULL default '0',
21    username varchar(50) NOT NULL default '',    username varchar(50) NOT NULL default '',
22    startentry mediumint(5) NOT NULL default '0',    startentry mediumint(5) NOT NULL default '0',
23    endentry mediumint(5) NOT NULL default '0',    endentry mediumint(5) NOT NULL default '0',
24    PRIMARY KEY  (qid),    PRIMARY KEY (qid),
25    KEY uid (uid)    KEY uid (uid)
26  );  );
27    
# Line 200  function advogato_import_diary_user() { Line 200  function advogato_import_diary_user() {
200        '#value' => t('Queue Import')        '#value' => t('Queue Import')
201      );      );
202    
203      print theme('page', form_render($form));      print theme('page', drupal_get_form('advogato_import', $form));
204    }    }
205    else {    else {
206      drupal_not_found();      drupal_not_found();
# Line 225  function advogato_import_cron() { Line 225  function advogato_import_cron() {
225        $node->sticky   = variable_get('advogato_import_sticky', 0);        $node->sticky   = variable_get('advogato_import_sticky', 0);
226        $node->comment  = variable_get('advogato_import_comment', 0); // 0 = disabled        $node->comment  = variable_get('advogato_import_comment', 0); // 0 = disabled
227        $node->format   = 3; // Drupal's default for Full HTML; Advogato already did filtering        $node->format   = 3; // Drupal's default for Full HTML; Advogato already did filtering
228        $node->files   = array();        $node->files    = array();
229    
230        while($queue = db_fetch_object($result)) {        while($queue = db_fetch_object($result)) {
231          $account    = user_load(array('uid' => $queue->uid));          $account    = user_load(array('uid' => $queue->uid));
# Line 253  function advogato_import_cron() { Line 253  function advogato_import_cron() {
253            // node_submit() would probably be more "proper", but it calls            // node_submit() would probably be more "proper", but it calls
254            // drupal_set_message() on each execution, which can be messy            // drupal_set_message() on each execution, which can be messy
255            // on users' next page load with lots of imports.            // on users' next page load with lots of imports.
256            $nid = node_save($node);            var_dump(node_save($node));
257    
258            if($nid) {            // node_submit() normally calls this
259              // node_submit() normally calls this            watchdog('content', t('%type: added %title.',
260              watchdog('content', t('%type: added %title.',                     array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))),
261                       array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))),                     WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
262                       WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));  
263              // update queue
264              // update queue            $asc === true ? $queue->startentry++ : $queue->startentry--;
265              $asc === true ? $queue->startentry++ : $queue->startentry--;            db_query('UPDATE {advogato_import} SET startentry = %d WHERE qid = %d', $queue->startentry, $queue->qid);
266              db_query('UPDATE {advogato_import} SET startentry = %d WHERE qid = %d', $queue->startentry, $queue->qid);            $abs--;
267              $abs -= 1;            $loop_limit--;
             $loop_limit -= 1;  
           }  
268          } while(($cron_limit === 0 xor $loop_limit > 0) && $abs >= 0);          } while(($cron_limit === 0 xor $loop_limit > 0) && $abs >= 0);
269    
270          if(($asc === true && $queue->startentry > $queue->endentry) || ($asc === false && $queue->startentry < $queue->endentry)) {          if(($asc === true && $queue->startentry > $queue->endentry) || ($asc === false && $queue->startentry < $queue->endentry)) {

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

  ViewVC Help
Powered by ViewVC 1.1.2