User login

Drupal Development

Fixing file paths after a change in location of a site's files directory

If, like Agaric, you're moving from multisite to separate installations for each site (or vice versa) you may find your user-uploaded file paths changing. Drag.

The solution is updating your database, and you can replace part of the file path with straight SQL:

UPDATE files SET filepath = REPLACE(filepath, "sites/help4computers.com/files/", "sites/default/files/")

Drupal function to give path to files directory

All Agaric wanted was the Drupal function to give the path to files directory (which Drupal core itself should probably use instead of embedding the full filepath in the files database), and finding it was soooooo much harder to find than it should have been.

The Drupal function which we suppose we ought to use is file_create_url().

See http://api.drupal.org/api/function/file_create_url/5

Agaric wants Drupal to upload files with any or no extension and stop being a pain about it

Agaric is not alone: Allow any files to be uploaded or make "Permitted upload file extensions" a required field

The workaround of adding the file name to the "extension" list didn't work for us though for a file called "Capfile" (with no extension, of course).

Adding a .txt extension to the file for now. But may I say: annoying!

Resolution

CVS commands for branching a Drupal 5 module to Drupal 6

following add1sun's page: http://drupal.org/node/315987

Ebony-II:~ ben$ cd /RCS/
Ebony-II:RCS ben$ mkdir projects
Ebony-II:RCS ben$ cd projects/
Ebony-II:projects ben$ export CVSROOT=:pserver:agaric@cvs.drupal.org:/cvs/drupal-contrib
Ebony-II:projects ben$ cvs login


Logging in to :pserver:agaric@cvs.drupal.org:2401/cvs/drupal-contrib
CVS password:

Upgrading Enabled Modules from Drupal 5 to Drupal 6

Reference

Converting 5.x modules to 6.x
http://drupal.org/node/114774

Upgrading your menu system from 5.x to 6.x
http://drupal.org/node/103114

Changes specific to the Enabled Modules module

Description replaced with a serialized info column in system table.

Related to Enabled Modules

There are at least two other modules in a similar space as Agaric's Enabled Modules:

(and this page will list them when i find them!)

A Drupal 4.7 snippet, List all enabled modules for a 'colophon' or 'about' page.

Another reason user module needs to be rewritten... or maybe this is just a file handling issue

I'm blaming user module even though I know intimately that I shouldn't: a 2 hour estimate to add user picture upload to the client's custom registration form has become a journey through HTML form and PHP file handling hell because even Drupal core doesn't let you upload a user picture when uploading. Finally just put it on the second page of the client's two screen login process.

Wrote a module almost just like http://drupal.org/project/reg_with_pic

Calculate the sum of an entire result set of values with a single SQL query

As tested in phpMyAdmin:

SELECT SUM( `value` )
FROM `dru_ec_product_zing_auction` AS za
LEFT JOIN `dru_node` AS n ON za.nid = n.nid
WHERE STATUS > 0;

Drupalized:
SELECT SUM(value) FROM {ec_product_zing_auction} AS za LEFT JOIN {node} AS n ON za.nid = n.nid WHERE status > 0

As actually used in a Drupal module, zing_auction:

Automatically putting a user's post into an organic group

The final result is in the (as yet unreleased, but if you want the code we'll send it) special treatment module.

Some test ouput and discovery of key function along the way:

Don't try to use last insert ID to get the just-submitted user

<?php
// this does not work-- it grabs the ID of the last log message!!
  $uid = db_result(db_query('SELECT LAST_INSERT_ID()'));
drupal_set_message('uid: '. $uid);
?>

Resolution

Syndicate content