4 * @file src/Model/Item.php
7 namespace Friendica\Model;
9 use Friendica\Core\Worker;
10 use Friendica\Model\Term;
13 require_once 'include/tags.php';
14 require_once 'include/threads.php';
19 * @brief Update existing item entries
21 * @param array $fields The fields that are to be changed
22 * @param array $condition The condition for finding the item entries
24 * In the future we may have to change permissions as well.
25 * Then we had to add the user id as third parameter.
27 * A return value of "0" doesn't mean an error - but that 0 rows had been changed.
29 * @return integer|boolean number of affected rows - or "false" if there was an error
31 public static function update(array $fields, array $condition)
33 if (empty($condition) || empty($fields)) {
37 $success = dba::update('item', $fields, $condition);
43 $rows = dba::affected_rows();
45 // We cannot simply expand the condition to check for origin entries
46 // The condition needn't to be a simple array but could be a complex condition.
47 $items = dba::select('item', ['id', 'origin'], $condition);
48 while ($item = dba::fetch($items)) {
49 // We only need to notfiy others when it is an original entry from us
50 if (!$item['origin']) {
54 create_tags_from_item($item['id']);
55 Term::createFromItem($item['id']);
56 update_thread($item['id']);
58 Worker::add(PRIORITY_HIGH, "Notifier", 'edit_post', $item['id']);