/[drupal]/contributions/modules/links/update-webstory.php
ViewVC logotype

Contents of /contributions/modules/links/update-webstory.php

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


Revision 1.2 - (show annotations) (download) (as text)
Thu Feb 2 04:50:59 2006 UTC (3 years, 9 months ago) by syscrusher
Branch: MAIN
CVS Tags: DRUPAL-5--1-12-BETA1, DRUPAL-5--1-7, DRUPAL-5--1-9, DRUPAL-5--1-8, DRUPAL-5--1-5, DRUPAL-5--1-6, DRUPAL-5--1-3, DRUPAL-5--1-2, DRUPAL-6--1-0, DRUPAL-6--1-1, DRUPAL-6--1-2, DRUPAL-4-7--1-1, DRUPAL-5--1-4, DRUPAL-6--1-0-BETA15, DRUPAL-6--1-0-BETA14, DRUPAL-6--1-0-BETA13, DRUPAL-6--1-0-BETA12, DRUPAL-6--1-0-BETA11, DRUPAL-6--1-0-BETA10, DRUPAL-5--1-11, DRUPAL-5--1-10, DRUPAL-5--1-13, DRUPAL-5--1-12, DRUPAL-6--1-0-BETA9, DRUPAL-6--1-0-BETA8, DRUPAL-6--1-0-BETA3, DRUPAL-6--1-0-BETA2, DRUPAL-6--1-0-BETA1, DRUPAL-6--1-0-BETA7, DRUPAL-6--1-0-BETA6, DRUPAL-6--1-0-BETA5, HEAD
Branch point for: DRUPAL-4-7, DRUPAL-6--1, DRUPAL-6--2, DRUPAL-5
Changes since 1.1: +4 -4 lines
File MIME type: text/x-php
Lots of improvements to the update scripts, including the addition of a
new script for recent weblinks versions. The latter is UNTESTED as of now
due to lack of a test site. Test reports welcome if someone else gets
time to test it before I do.

Also added first draft of upgrade instructions.
1 <?php
2 // $Id: update-webstory.php,v 1.1 2005/06/10 04:29:09 syscrusher Exp $
3
4 /**
5 * @file
6 * PHP page for updating legacy "webstory" nodes. "webstory.module" was never
7 * released into production, but is used on Syscrusher's personal sites. This
8 * script is released in hopes that it might be useful to someone as an
9 * example, since I had to write it for myself anyway.
10 *
11 * THIS CODE IS EXPERIMENTAL -- NOT FOR PRODUCTION USE
12 */
13
14 include_once 'includes/bootstrap.inc';
15 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
16
17 $sql = "SELECT n.nid, n.title, ws.* FROM {node} n INNER JOIN {webstory} ws ON n.nid=ws.nid WHERE n.type='webstory' ORDER BY n.nid DESC LIMIT 1000";
18 $sql2 = "INSERT INTO {links_node} (lid,nid,link_title,weight,clicks,module) values (%d,%d,'%s',-5,%d,'links_related')";
19
20 print('<html><body>');
21 $count=0;
22 $result = db_query($sql);
23 while ($row = db_fetch_object($result)) {
24 $n_url = links_normalize_url($row->url);
25 $lid = links_put_link($n_url);
26 links_delete_links_for_node($row->nid);
27 $title = links_suggest_link_title($lid, '');
28 $clicks = $row->click;
29 $result2 = db_query($sql2, $lid, $row->nid, $title, $clicks);
30 $result3 = db_query("UPDATE {node} SET TYPE='story' WHERE nid=%d", $row->nid);
31 $count++;
32 }
33 print("<P>Processed $count webstory records. The script limits the number in one run to prevent timeouts. If no errors, rerun this script until the count is zero; it may take several iterations.");
34 print('</body></html>');
35 ?>

  ViewVC Help
Powered by ViewVC 1.1.2