/** * reindex solr core if needed * @return void */ protected function reindex() { $solr = new Solr\Client(); $solr->updateTree(array('all' => true, 'nolimit' => true)); }
/** * save or create an object * @param array $p object properties * @return json responce */ public function save($p) { $d = Util\toJSONArray($p['data']); // check if need to create object instead of update if (empty($d['id']) || !is_numeric($d['id'])) { return $this->create($d); } // SECURITY: check if current user has write access to this action if (!Security::canWrite($d['id'])) { throw new \Exception(L\get('Access_denied')); } /* prepare params */ if (empty($d['date']) && !empty($d['date_start'])) { $d['date'] = $d['date_start']; } /* end of prepare params */ // update object $object = $this->getCachedObject($d['id']); //set sys_data from object, it can contain custom data //that shouldn't be overwritten $d['sys_data'] = $object->getSysData(); $object->update($d); Objects::updateCaseUpdateInfo($d['id']); /* updating saved document into solr directly (before runing background cron) so that it'll be displayed with new name without delay */ if (!\CB\Config::getFlag('disableSolrIndexing')) { $solrClient = new Solr\Client(); $solrClient->updateTree(array('id' => $d['id'])); //running background cron to index other nodes $solrClient->runBackgroundCron(); } return $this->load($d); }
public function rename($p) { $id = explode('/', $p['path']); $id = array_pop($id); $p['name'] = trim($p['name']); if (!is_numeric($id) || empty($p['name'])) { return array('success' => false); } /* check security access */ if (!Security::canWrite($id)) { throw new \Exception(L\get('Access_denied')); } DB\dbQuery('UPDATE tree SET name = $1 WHERE id = $2', array($p['name'], $id)) or die(DB\dbQueryError()); switch (Objects::getType($id)) { case 'file': $p['name'] = Purify::filename($p['name']); DB\dbQuery('UPDATE files SET name = $1 WHERE id = $2', array($p['name'], $id)) or die(DB\dbQueryError()); break; } /*updating renamed document into solr directly (before runing background cron) so that it'll be displayed with new name without delay*/ $solrClient = new Solr\Client(); $solrClient->updateTree(array('id' => $id)); //running background cron to index other nodes $solrClient->runBackgroundCron(); $p['name'] = htmlspecialchars($p['name'], ENT_COMPAT); //get pid $pid = null; $res = DB\dbQuery('SELECT pid FROM tree WHERE id = $1', $id) or die(DB\dbQueryError()); if ($r = $res->fetch_assoc()) { $pid = $r['pid']; } $res->close(); return array('success' => true, 'data' => array('id' => $id, 'pid' => $pid, 'newName' => $p['name'])); }
/** * method called after a task have been updated * used now to update solr and cases date * @param int $taskId * @return void */ protected function afterUpdate($taskId) { Objects::updateCaseUpdateInfo($taskId); $solr = new Solr\Client(); $solr->updateTree(array('id' => $taskId)); }
public function rename($p) { $id = explode('/', $p['path']); $id = array_pop($id); $p['name'] = trim($p['name']); if (!is_numeric($id) || empty($p['name'])) { return array('success' => false); } /* check security access */ if (!Security::canWrite($id)) { throw new \Exception(L\get('Access_denied')); } $p['name'] = Purify::filename($p['name']); $rez = array('success' => true, 'data' => array('id' => $id, 'pid' => null, 'newName' => $p['name'])); $objectType = Objects::getType($id); if ($objectType == 'shortcut') { $r = DM\Tree::read($id); if (!empty($r['target_id'])) { $id = $r['target_id']; $objectType = Objects::getType($id); } } DM\Tree::update(array('id' => $id, 'name' => $p['name'])); if ($objectType == 'file') { DM\Files::update(array('id' => $id, 'name' => $p['name'])); } /*updating renamed document into solr directly (before runing background cron) so that it'll be displayed with new name without delay*/ $solrClient = new Solr\Client(); $solrClient->updateTree(array('id' => $id)); //running background cron to index other nodes $solrClient->runBackgroundCron(); $p['name'] = htmlspecialchars($p['name'], ENT_COMPAT); //get pid $r = DM\Tree::read($rez['data']['id']); if (!empty($r['pid'])) { $rez['data']['pid'] = $r['pid']; } return $rez; }