| 1 |
<?php |
<?php |
| 2 |
/************************************* |
/************************************* |
| 3 |
* Demexp module for a Drupal demexp client |
* Demexp module for a Drupal demexp client |
| 4 |
* $Id: demexp.module,v 1.26 2006/10/14 09:56:08 augustin Exp $ |
* $Id: demexp.module,v 1.27 2006/10/14 10:17:16 augustin Exp $ |
| 5 |
* Copyright Augustin Masquilier, 2006. |
* Copyright Augustin Masquilier, 2006. |
| 6 |
* This module is released under the terms of the GPL. |
* This module is released under the terms of the GPL. |
| 7 |
*************************************/ |
*************************************/ |
| 790 |
_demexp_update_question_node($ds_question); |
_demexp_update_question_node($ds_question); |
| 791 |
} |
} |
| 792 |
} |
} |
| 793 |
|
|
| 794 |
|
// Update tags |
| 795 |
|
// -------------------- |
| 796 |
|
// In order to avoid repeated SQL queries in a big loop, we start with one simple query, |
| 797 |
|
// and then check which $ds_timestamps['gt_tag'] have not been considered yet. |
| 798 |
|
$result = db_query('SELECT * FROM {demexp_tags}'); |
| 799 |
|
while ($tag = db_fetch_object($result)) { |
| 800 |
|
if ($tag->ds_a_tag_timestamp < $ds_timestamps['gt_tag'][$tag->ds_a_tag_id]) { |
| 801 |
|
$ds_tag = _contact_demexp_server('tag_info', 0, (int) $tag->ds_a_tag_id, 1); |
| 802 |
|
_demexp_update_tags($ds_tag, TRUE); |
| 803 |
|
} |
| 804 |
|
// this tag has been dealt with: it can now be discarded. |
| 805 |
|
unset($ds_timestamps['gt_tag'][$tag->ds_a_tag_id]); |
| 806 |
|
} |
| 807 |
|
// Now, we deal with the tags that have never been imported: |
| 808 |
|
foreach ($ds_timestamps['gt_tag'] AS $ds_tag_id => $timestamp) { |
| 809 |
|
$ds_tag = _contact_demexp_server('tag_info', 0, (int) $ds_tag_id , 1); |
| 810 |
|
if (!empty($ds_tag)) { |
| 811 |
|
_demexp_update_tags($ds_tag, TRUE); |
| 812 |
|
} |
| 813 |
|
} |
| 814 |
} |
} |
| 815 |
|
|
| 816 |
/************************************* |
/************************************* |
| 834 |
$tag['a_tag_label'] = substr($tag['a_tag_label'], $len+2); |
$tag['a_tag_label'] = substr($tag['a_tag_label'], $len+2); |
| 835 |
$tid = db_result(db_query('SELECT tid FROM {demexp_tags} WHERE ds_a_tag_id = %d', $tag['a_tag_id'])); |
$tid = db_result(db_query('SELECT tid FROM {demexp_tags} WHERE ds_a_tag_id = %d', $tag['a_tag_id'])); |
| 836 |
db_query('UPDATE {term_data} SET name = "%s" WHERE tid = %d', $tag['a_tag_label'], $tid); |
db_query('UPDATE {term_data} SET name = "%s" WHERE tid = %d', $tag['a_tag_label'], $tid); |
| 837 |
db_query("UPDATE {demexp_tags} SET tag_hierarchy = '%s' WHERE ds_a_tag_id = %d", $key, $tag['a_tag_id']); |
db_query("UPDATE {demexp_tags} SET tag_hierarchy = '%s', ds_a_tag_timestamp = %d WHERE ds_a_tag_id = %d", $key, $tag['a_tag_timestamp'], $tag['a_tag_id']); |
| 838 |
_demexp_tag_hierarchy($tid, $key); |
_demexp_tag_hierarchy($tid, $key); |
| 839 |
} |
} |
| 840 |
} |
} |