| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install()
|
| 6 |
*/
|
| 7 |
function signature_forum_install() {
|
| 8 |
switch ($GLOBALS['db_type']) {
|
| 9 |
case 'mysql':
|
| 10 |
case 'mysqli':
|
| 11 |
db_query("UPDATE {comments} c INNER JOIN {users} u ON c.uid=u.uid
|
| 12 |
SET c.comment=left(c.comment, length(c.comment) - length(u.signature))
|
| 13 |
WHERE right(c.comment, length(u.signature)) LIKE u.signature;");
|
| 14 |
db_query("CREATE TABLE {users_signature} (
|
| 15 |
uid int unsigned NOT NULL default '0',
|
| 16 |
signature MEDIUMTEXT default NULL,
|
| 17 |
PRIMARY KEY (uid)
|
| 18 |
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
|
| 19 |
db_query("INSERT INTO {users_signature} (uid, signature)
|
| 20 |
SELECT uid, signature
|
| 21 |
FROM {users}
|
| 22 |
WHERE signature<>''");
|
| 23 |
db_query("UPDATE {users} SET signature=NULL");
|
| 24 |
break;
|
| 25 |
}
|
| 26 |
|
| 27 |
cache_clear_all(NULL, 'cache_page');
|
| 28 |
cache_clear_all(NULL, 'cache_filter');
|
| 29 |
}
|
| 30 |
|
| 31 |
/**
|
| 32 |
* Implementation of hook_uninstall()
|
| 33 |
*/
|
| 34 |
function signature_forum_uninstall() {
|
| 35 |
switch ($GLOBALS['db_type']) {
|
| 36 |
case 'mysql':
|
| 37 |
case 'mysqli':
|
| 38 |
db_query("UPDATE {users}, {users_signature}
|
| 39 |
SET {users}.signature={users_signature}.signature
|
| 40 |
WHERE {users}.uid={users_signature}.uid");
|
| 41 |
db_query("DROP TABLE {users_signature}");
|
| 42 |
db_query("DELETE FROM {variable} WHERE name LIKE 'signature\_forum\_%'");
|
| 43 |
break;
|
| 44 |
}
|
| 45 |
}
|
| 46 |
|
| 47 |
/**
|
| 48 |
* Implementation of hook_update()
|
| 49 |
*/
|
| 50 |
function signature_forum_update_1() {
|
| 51 |
$items = array();
|
| 52 |
switch ($GLOBALS['db_type']) {
|
| 53 |
case 'mysql':
|
| 54 |
case 'mysqli':
|
| 55 |
$items[] = update_sql("UPDATE {comments} c INNER JOIN {users_signature} u ON c.uid=u.uid
|
| 56 |
SET c.comment=left(c.comment, length(c.comment) - length(u.signature))
|
| 57 |
WHERE right(c.comment, length(u.signature)) LIKE u.signature;");
|
| 58 |
break;
|
| 59 |
}
|
| 60 |
|
| 61 |
cache_clear_all(NULL, 'cache_page');
|
| 62 |
cache_clear_all(NULL, 'cache_filter');
|
| 63 |
return $items;
|
| 64 |
}
|