/** * Delete photo record * * @param int photo id * * @return boolean */ public function delete($photoId) { /** Get filedata refcount */ $fileDataRecord = $this->fetchFileDataRecord($photoId); $existing = $this->nodeApi->getNode($photoId); if ($result = parent::delete($photoId)) { $refCount = $fileDataRecord["refcount"] - 1; $data = array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, vB_dB_Query::CONDITIONS_KEY => array('filedataid' => $fileDataRecord["filedataid"]), 'refcount' => $refCount); $this->assertor->assertQuery("vBForum:filedata", $data); $this->nodeApi->clearCacheEvents(array($photoId, $existing['parentid'])); return $result; } else { return false; } }
/** Remove an attachment * @param INT nodeid * **/ public function delete($nodeid) { //We need the parent id. After deletion we may need to set hasphoto = 0; $existing = $this->nodeApi->getNode($nodeid); $this->removeAttachment($nodeid); parent::delete($nodeid); $photo = $this->assertor->getRow('vBForum:node', array('contenttypeid' => $this->contenttypeid, 'parentid' => $existing['parentid'])); //If we got empty or error, there are no longer any attachments. if (!empty($existing['parentid']) and (empty($photo) or !empty($photo['errors']))) { $this->assertor->assertQuery('vBForum:node', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_UPDATE, 'hasphoto' => 0, vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'nodeid', 'value' => $existing['parentid'], 'operator' => vB_dB_Query::OPERATOR_EQ)))); } $this->nodeApi->clearCacheEvents(array($nodeid, $existing['parentid'])); }
function delete($nodeid) { if (empty($nodeid)) { return false; } // prevent deleting of top level channels if (in_array($nodeid, vB_Api::instanceInternal('content_channel')->fetchTopLevelChannelIds())) { throw new vB_Exception_Api('cant_delete_top_level'); } // get the direct children. $children_nodes = vB::getDbAssertor()->assertQuery('vBForum:getChildrenOnly', array('nodeid' => $nodeid)); $nodeids = array(); $children_by_type = array(); foreach ($children_nodes as $node) { $children_by_type[$node['contenttypeid']][$node['nodeid']] = $node['nodeid']; $nodeids[] = $node['nodeid']; } foreach ($children_by_type as $contenttypeid => $nodes) { $contentLib = vB_Library_Content::getContentLib($contenttypeid); $contentLib->deleteChildren($nodes); } if (!empty($nodeids)) { vB_Search_Core::instance()->deleteBulk($nodeids); } // deleting the node $success = parent::delete($nodeid); // delete pages and routes $this->deleteChannelPages($nodeid); vB_Cache::instance()->event('vB_ChannelStructure_chg'); vB::getUserContext()->rebuildGroupAccess(); vB_Channel::rebuildChannelTypes(); return $success; }