public function restore($paths) { if (!is_array($paths)) { $paths = array($paths); } /* collecting ids from paths */ $ids = array(); foreach ($paths as $path) { $id = explode('/', $path); $id = array_pop($id); if (!is_numeric($id)) { return array('success' => false); } if (!Security::canDelete($id)) { throw new \Exception(L\get('Access_denied')); } $ids[] = intval($id); } if (empty($ids)) { return array('success' => false); } /* before deleting we should check security for specified paths and all children */ /* if access is granted then setting dstatus=0 for specified ids all their children /**/ foreach ($ids as $id) { $obj = Objects::getCustomClassByObjectId($id); $obj->restore(); } Solr\Client::runCron(); return array('success' => true, 'ids' => $ids); }
// join with tree table if filter not empty if (!empty($where)) { $where = ' JOIN tree t ON o.id = t.id ' . $where; } //start the process //select all objects that have data in "objects" table $res = DB\dbQuery('SELECT count(*) `nr` FROM objects o' . $where) or die(DB\dbQueryError()); if ($r = $res->fetch_assoc()) { echo "Total objects: " . $r['nr'] . "\n"; } $res->close(); //iterate and update each object $i = 0; DB\startTransaction(); $res = DB\dbQuery('SELECT o.id FROM objects o' . $where) or die(DB\dbQueryError()); while ($r = $res->fetch_assoc()) { if ($i > 100) { $i = 0; echo '.'; } $obj = Objects::getCustomClassByObjectId($r['id']); if (!empty($obj)) { $obj->updateSolrData(); } $i++; } $res->close(); DB\commitTransaction(); echo "\nDone";