4 * Ajatus - Distributed CRM
6 * Copyright (c) 2008 Jerry Jalava <jerry.jalava@gmail.com>
7 * Copyright (c) 2008 Nemein Oy <http://nemein.com>
8 * Website: http://ajatus.info
9 * Licensed under the GPL license
10 * http://www.gnu.org/licenses/gpl.html
14 class ajatus_actions_undelete
17 private $configuration;
19 public function __construct(&$connection, &$configuration)
21 $this->connection
=& $connection;
22 $this->configuration
=& $configuration;
25 public function __get($id)
27 return $this->by_id($id);
30 public function __set($id, $value)
38 public function by_id($id)
40 $db_name = $this->configuration
['content_db'];
41 if (! isset($this->connection
->$db_name->document
->$id))
46 return $this->one(&$this->connection
->$db_name->document
->$id);
49 public function one(&$object)
51 if (! is_a($object, 'couchdb_documents_document'))
53 //PONDER: should we throw exception ajatus_action_exception('Given object is not of type "couchdb_documents_document"!') here?
57 $metadata = new ajatus_helpers_metadata(&$object->value
->metadata
);
58 $metadata->update('deleted', false);
59 $metadata->update('revised', ajatus_helpers_date
::unixtime_to_jsdatetime());
60 $metadata->update('revisor', $GLOBALS['ajatus']->user
['email']);
62 return $object->save();
65 public function many(array $objects)
67 foreach ($objects as $object)