Make the tag result list scrollable so long tags can be read
[ajatus.git] / plugins / ajatus / actions / undelete.php
blob99a4e4006da2c3027d4ad242fd8665aed8028e3a
1 <?php
2 /**
3 * This file is part of
4 * Ajatus - Distributed CRM
5 *
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
16 private $connection;
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)
32 if ($value === true)
34 $this->by_id($id);
38 public function by_id($id)
40 $db_name = $this->configuration['content_db'];
41 if (! isset($this->connection->$db_name->document->$id))
43 return false;
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?
54 return false;
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)
69 $this->one(&$object);
72 return true;