00001 <?php
00002
00003
00004
00005
00006
00007
00008 class Confirmations {
00009
00010
00011
00012
00013
00014 public static function create($id_item, $data, $action, &$result = null) {
00015 self::remove_expired();
00016
00017 $params = array(
00018 'id_item' => $id_item,
00019 'data' => $data,
00020 'action' => $action
00021 );
00022 $cmd = CommandsFactory::create_command('confirmations', 'create', $params);
00023 $ret = $cmd->execute();
00024 if (!is_null($result)) {
00025 $result = $cmd->get_result();
00026 }
00027 return $ret;
00028 }
00029
00030
00031
00032
00033 public static function create_confirmation_handler($id, $code) {
00034 self::remove_expired();
00035
00036 $confirmation = new DAOConfirmations();
00037 $confirmation->code = $code;
00038 $confirmation->id = $id;
00039 if ($confirmation->find(IDataObject::AUTOFETCH)) {
00040 return $confirmation->create_handler();
00041 }
00042
00043 return new ConfirmationHandlerBase(false);
00044 }
00045
00046
00047
00048
00049
00050
00051 public static function remove_expired() {
00052 $c = new DAOConfirmations();
00053
00054
00055
00056
00057 $c->add_where('expirationdate', '<', time() - 30 * GyroDate::ONE_DAY);
00058 return $c->delete(DataObjectBase::WHERE_ONLY);
00059 }
00060 }