Index: attachment.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/attachment/attachment.install,v
retrieving revision 1.3
diff -u -r1.3 attachment.install
--- attachment.install 17 Jul 2007 19:50:04 -0000 1.3
+++ attachment.install 4 Nov 2007 11:56:27 -0000
@@ -10,6 +10,23 @@
}
/**
+ * Add weight column to database table
+ */
+function attachment_update_2() {
+ $ret = array();
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ $ret[] = update_sql("ALTER TABLE {attachment} ADD COLUMN weight int(10) NOT NULL default 0;");
+ break;
+ case 'pgsql':
+ $ret[] = update_sql("alter table {attachment} add column weight integer not null;");
+ break;
+ }
+ return $ret;
+}
+
+/**
* Install the initial schema.
*/
function attachment_install() {
@@ -23,6 +40,7 @@
aid int(10) unsigned NOT NULL,
nid int(10) unsigned NOT NULL,
fid int(10) unsigned NOT NULL,
+ weight int(10) NOT NULL default 0,
filename varchar(255) NOT NULL,
title varchar(255) NOT NULL,
description varchar(255) NOT NULL,
@@ -41,6 +59,7 @@
aid serial primary key,
nid integer not null,
fid integer not null,
+ weight integer not null,
filename varchar(255) not null,
title varchar(255) not null,
description varchar(255) not null,
Index: attachment.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/attachment/attachment.module,v
retrieving revision 1.20
diff -u -r1.20 attachment.module
--- attachment.module 2 Aug 2007 17:38:57 -0000 1.20
+++ attachment.module 4 Nov 2007 11:58:01 -0000
@@ -1,5 +1,5 @@
'checkbox', '#return_value'=>1, '#default_value'=>$attachment['hidden']);
$form['attachments'][$key]['title'] = array('#type'=>'textfield', '#size'=>30, '#maxlength'=>255, '#default_value'=>$attachment['title']);
$form['attachments'][$key]['description'] = array('#type'=>'textfield', '#size'=>100, '#maxlength'=>255, '#default_value'=>$attachment['description']);
+ $form['attachments'][$key]['weight'] = array('#type'=>'weight','#default_value'=>$attachment['weight']);
$form['attachments'][$key]['display'] = array('#type'=>'markup', '#value'=> 'Filename:'. $attachment['filename'] .'
URL:');
}
@@ -126,11 +127,11 @@
if (!$attachment['deleted']) {
module_invoke('filemanager', 'promote_working', $attachment['fid']);
if ($attachment['aid']) {
- db_query("UPDATE {attachment} SET title='%s', description = '%s', size=%d, hidden='%s' WHERE aid=%d", $attachment['title'], $attachment['description'], $attachment['size'], $attachment['hidden'], $attachment['aid']);
+ db_query("UPDATE {attachment} SET title='%s', description = '%s', size=%d, hidden='%s', weight='%d' WHERE aid=%d", $attachment['title'], $attachment['description'], $attachment['size'], $attachment['hidden'], $attachment['weight'], $attachment['aid']);
}
else {
$aid = db_next_id('{attachment}_aid');
- db_query("INSERT INTO {attachment} (aid,title,description,nid,fid,filename,size,hidden) VALUES (%d,'%s','%s',%d,%d,'%s',%d,'%s')", $aid, $attachment['title'],$attachment['description'],$node->nid, $attachment['fid'], $attachment['filename'], $attachment['size'], $attachment['hidden']);
+ db_query("INSERT INTO {attachment} (aid,title,description,nid,fid,filename,size,hidden,weight) VALUES (%d,'%s','%s',%d,%d,'%s',%d,'%s',%d)", $aid, $attachment['title'],$attachment['description'],$node->nid, $attachment['fid'], $attachment['filename'], $attachment['size'], $attachment['hidden'], $attachment['weight']);
}
}
else {
@@ -269,34 +270,37 @@
* Theme the attachment form
*/
function theme_attachment_form($form) {
+ _attachments_enable_dragdrop();
$output = '';
$header = array(
t('Delete'),
t('Hidden'),
+ t('Weight'),
t('Title'),
t('Description'),
);
$rows = array();
+
+$output .= "