Converting Drupal Workspace module to mySQL 3.x

See here for an explanation. Basically, this is how thepoorhouse.org.uk converted the Drupal module "Workspace" which is designed for mySQL 4 and above to run on mySQL 3.

Some people had come up with solutions, but they didn't work straight off with the current releases of Workspace. Very close, but not quite a cigar. So, from memory, here's what the Poorhouse did to fix it - very much based on the previously mentioned solution. The final, working, file is attached below. It's not perfect, and the code modifications might be dodgy in places - the Poorhouse is not a good PHP coder - but it works as well as we need it to. The line numbers only correspond to the release dated 23/04/06, and may be a tad out anyway due to much editing and deletes during the trial and error that is much the preferred coding style around here.

Firstly rename workspace_list() to function function _callback_workspace_list($sql, $listfiles) (line 150)

Get rid of the two existing assignments to the $sql variables in that function (2 lines - line numbers around 175 and 189ish)

Put a if($listfiles) around the section that writes out file attachment list. Yes, this is an extremely lame way of doing it, but it works and the Poorhouse is limited in time and expertise - line 283ish.

So you get

// build the attachment listing
if ($listfiles)
{
  $rows = array();
...blah blah...
    $output .= theme('table', $header, $rows);
  }

Add the workspace_list() function - similar to this patch but slightly different.

function workspace_list() {
global $user;
$output = '';
$output .= workspace_addform();
$output .= '<p>&nbsp;</p>';
$sql_1 = "SELECT n.nid, n.type, 0 AS cid, n.title, n.status, n.changed, s.comment_count, 1 AS node, n.uid ";
$sql_1 .= "FROM {node} n LEFT OUTER JOIN {node_comment_statistics} s ON n.nid = s.nid ";
$sql_1 .= "WHERE n.uid = $user->uid ";
$output .= '<h2>'.t('Publications').'</h2>';
$output .= _callback_workspace_list($sql_1, true);
$sql_2 = "SELECT c.nid AS nid, '' AS type, c.cid, c.subject AS title, c.status, c.timestamp AS changed, c.pid, 0 ";
$sql_2 .= "FROM {comments} AS c ";
$sql_2 .= "WHERE c.uid = $user->uid";
$output .= '<br><br><h2>'.t('Comments').'</h2>';
$output .= _callback_workspace_list($sql_2, false);
return $output;
}

The module with the above amends...and whatever else the Poorhouse forgot to mention...along with a bug fix detailed here is attached below.


AttachmentSize
workspace.zip3.66 KB

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <del> <p>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You may use [acidfree:xx] tags to display acidfree videos or images inline.
  • Images can be added to this post.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 7 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.