@ -24,14 +24,14 @@ class VacationHandler {
$new_aliases[] = $alias;
$new_aliases[] = $alias;
}
}
}
}
$ah->update($new_aliases, '', false);
$ah->update($new_aliases, '', false); # TODO: supress logging in AliasHandler if called from VacationHandler (VacationHandler should log itsself)
// tidy up vacation table.
// tidy up vacation table.
$vacation_data = array(
$vacation_data = array(
'active' => db_get_boolean(false),
'active' => db_get_boolean(false),
);
);
$result = db_update('vacation', 'email', $this->username, $vacation_data, array() );
$result = db_update('vacation', 'email', $this->username, $vacation_data);
$result = db_delete('vacation_notification', 'on_vacation', $this->username, array() );
$result = db_delete('vacation_notification', 'on_vacation', $this->username);
# TODO db_log() call (maybe except if called from set_away?)
# TODO db_log() call (maybe except if called from set_away?)
/* crap error handling; oh for exceptions... */
/* crap error handling; oh for exceptions... */
return true;
return true;
@ -117,14 +117,15 @@ class VacationHandler {
$table_vacation = table_by_key('vacation');
$table_vacation = table_by_key('vacation');
$result = db_query("SELECT * FROM $table_vacation WHERE email = '$E_username'");
$result = db_query("SELECT * FROM $table_vacation WHERE email = '$E_username'");
if($result['rows'] == 1) {
if($result['rows'] == 1) {
$result = db_update('vacation', 'email', $this->username, $vacation_data, array() );
$result = db_update('vacation', 'email', $this->username, $vacation_data);
} else {
} else {
$result = db_insert('vacation', $vacation_data, array() );
$result = db_insert('vacation', $vacation_data);
}
}
# TODO error check
# TODO error check
# TODO wrap whole function in db_begin / db_commit (or rollback)?
# TODO wrap whole function in db_begin / db_commit (or rollback)?
$ah = new AliasHandler($this->username);
$ah = new AliasHandler($this->username);
$alias = $ah->get(true);
$alias = $ah->get(true);
$aliases = $ah->return;
$vacation_address = $this->getVacationAlias();
$vacation_address = $this->getVacationAlias();
$aliases[] = $vacation_address;
$aliases[] = $vacation_address;
return $ah->update($aliases, '', false);
return $ah->update($aliases, '', false);