| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id: class_media_mover_configuration.php,v 1.1.2.13 2009/10/19 02:52:57 arthuregg Exp $ |
// $Id: class_media_mover_configuration.php,v 1.1.2.14 2009/10/19 11:45:53 arthuregg Exp $ |
| 4 |
|
|
| 5 |
class media_mover_configuration { |
class media_mover_configuration { |
| 6 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
/** |
/** |
| 18 |
* Get the requested configuration |
* Load the requested configuration |
| 19 |
* |
* |
| 20 |
* @param $cid |
* @param $cid |
| 21 |
* int, configuration id |
* int, configuration id |
| 22 |
*/ |
*/ |
| 23 |
function get($cid) { |
function load($cid) { |
| 24 |
// get the configuration data |
// get the configuration data |
| 25 |
$configuration = db_fetch_object(db_query('SELECT * FROM {media_mover_configurations} WHERE cid = %d', $cid)); |
$configuration = db_fetch_object(db_query('SELECT * FROM {media_mover_configurations} WHERE cid = %d', $cid)); |
| 26 |
$this->cid = $cid; |
$this->cid = $cid; |
| 92 |
* true if the configuration can be locked, false if not |
* true if the configuration can be locked, false if not |
| 93 |
*/ |
*/ |
| 94 |
function step_lock() { |
function step_lock() { |
| 95 |
// lock the tables |
// Lock tables to make sure nobody else gets in our way |
|
|
|
|
// @TODO this is throwing weird errors- why? |
|
|
|
|
|
db_lock_table('media_mover_configurations'); |
|
| 96 |
db_lock_table('media_mover_steps'); |
db_lock_table('media_mover_steps'); |
|
// Get our status |
|
|
|
|
| 97 |
// check the status of this step |
// check the status of this step |
| 98 |
if (db_result(db_queryd('SELECT status FROM {media_mover_steps} WHERE cid = %d AND sid = %d', $this->cid, $this->sid )) != MMA_STEP_STATUS_RUNNING) { |
if (db_result(db_query('SELECT status FROM {media_mover_steps} WHERE cid = %d AND sid = %d', $this->cid, $this->sid )) != MMA_STEP_STATUS_RUNNING) { |
|
print "here"; |
|
| 99 |
// If this is a harvest operation, set this configuration's start run time |
// If this is a harvest operation, set this configuration's start run time |
| 100 |
// so we can calculate the next start time for uniquness |
// so we can calculate the next start time for uniquness |
| 101 |
if ($this->sid == 1) { |
if ($this->sid == 1) { |
| 102 |
db_query('UPDATE {media_mover_configurations} SET last_start_time = %d, start_time = %d WHERE cid = %d', $this->start_time, time(), $this->cid ); |
db_lock_table('media_mover_configurations'); |
| 103 |
|
db_query('UPDATE {media_mover_configurations} SET last_start_time = %d, start_time = %d WHERE cid = %d', $this->start_time, time(), $this->cid ); |
| 104 |
} |
} |
| 105 |
|
// we have to make sure the table is locked again |
| 106 |
|
db_lock_table('media_mover_steps'); |
| 107 |
// Update the status on our step |
// Update the status on our step |
| 108 |
db_query('UPDATE {media_mover_steps} SET status = "%s" WHERE cid = %d AND sid = %d', MMA_STEP_STATUS_RUNNING, $this->cid, $this->sid ); |
db_query('UPDATE {media_mover_steps} SET status = "%s" WHERE cid = %d AND sid = %d', MMA_STEP_STATUS_RUNNING, $this->cid, $this->sid ); |
| 109 |
$this->status = MMA_STEP_STATUS_RUNNING; |
$this->status = MMA_STEP_STATUS_RUNNING; |