| 1 |
<?php
|
| 2 |
function creTest_install()
|
| 3 |
{
|
| 4 |
|
| 5 |
drupal_set_message(t('!!! ya!!'));
|
| 6 |
switch ($GLOBALS['db_type']) {
|
| 7 |
case 'mysql':
|
| 8 |
case 'mysqli':
|
| 9 |
db_query("CREATE TABLE dev(
|
| 10 |
nid1 int(10) NOT NULL DEFAULT 0,
|
| 11 |
nid2 int(10) NOT NULL DEFAULT 0,
|
| 12 |
count int(10) NOT NULL DEFAULT 0,
|
| 13 |
sum int(10) NOT NULL DEFAULT 0,
|
| 14 |
PRIMARY KEY (nid1, nid2)
|
| 15 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 16 |
break;
|
| 17 |
case 'pgsql':
|
| 18 |
drupal_set_message(t('PGSQL is not supported'));
|
| 19 |
return;
|
| 20 |
break;
|
| 21 |
}
|
| 22 |
|
| 23 |
drupal_set_message(t('CRE Table created'));
|
| 24 |
|
| 25 |
|
| 26 |
// for every uid
|
| 27 |
$usersSQL = "SELECT uid from {users}";
|
| 28 |
|
| 29 |
$db_result = db_query($usersSQL);
|
| 30 |
if(!$db_result)
|
| 31 |
{
|
| 32 |
drupal_set_message(t('NO USERS!!'));
|
| 33 |
return;
|
| 34 |
}
|
| 35 |
|
| 36 |
while($row = db_fetch_array($db_result))
|
| 37 |
{
|
| 38 |
$userID = $row['uid'];
|
| 39 |
|
| 40 |
// for every node they rated
|
| 41 |
$node_result = db_query("SELECT content_id
|
| 42 |
FROM {votingapi_vote}
|
| 43 |
WHERE uid=%d",$userID);
|
| 44 |
if(!$node_result)
|
| 45 |
{
|
| 46 |
drupal_set_message(t('ERROR getting content_id from votingapi'));
|
| 47 |
return;
|
| 48 |
}
|
| 49 |
while($voting_record = db_fetch_array($node_result))
|
| 50 |
{
|
| 51 |
$nid = $voting_record['content_id'];
|
| 52 |
// run the build function
|
| 53 |
//echo "uid = $userID and nid = $nid<br>";
|
| 54 |
creTest_build($userID,$nid);
|
| 55 |
}
|
| 56 |
}
|
| 57 |
|
| 58 |
}
|