/** * Delete the file. * * @return null * @access public * @since 5/15/08 */ public function delete() { $query = new DeleteQuery(); $query->setTable('segue_site_theme_image'); $query->addWhereEqual('fk_theme', $this->themeId); $query->addWhereEqual('path', $this->path); $dbMgr = Services::getService("DatabaseManager"); $dbMgr->query($query, $this->databaseIndex); }
/** * Add a new image at the path specified. * * @param object Harmoni_Filing_FileInterface $image * @param string $filename * @param string $prefixPath * @return null * @access public * @since 5/15/08 */ public function addImage(Harmoni_Filing_FileInterface $image, $filename, $prefixPath = '') { if (!$this->canModify()) { throw new PermissionDeniedException(); } ArgumentValidator::validate($filename, NonzeroLengthStringValidatorRule::getRule()); $path = trim($prefixPath, '/'); if (strlen($path)) { $path = $path . '/' . $filename; } else { $path = $filename; } // Delete the old image $query = new DeleteQuery(); $query->setTable('segue_site_theme_image'); $query->addWhereEqual('fk_theme', $this->id); $query->addWhereEqual('path', $path); $dbc = Services::getService('DatabaseManager'); $dbc->query($query, $this->databaseIndex); $query = new InsertQuery(); $query->setTable('segue_site_theme_image'); $query->addValue('fk_theme', $this->id); $query->addValue('mime_type', $image->getMimeType()); $query->addValue('path', $path); $query->addValue('size', $image->getSize()); $query->addValue('data', base64_encode($image->getContents())); $dbc = Services::getService('DatabaseManager'); $dbc->query($query, $this->databaseIndex); }
/** * Remove an External group from a Hierarchy-based group. * * @param object Id $hierarchyParentId * @param object Id $externalChildId * @return void * @access public * @since 11/6/07 */ public function removeExternalChildGroup(Id $hierarchyParentId, Id $externalChildId) { // Remove the row. $query = new DeleteQuery(); $query->setTable('agent_external_children'); $query->addWhereEqual('fk_parent', $hierarchyParentId->getIdString()); $query->addWhereEqual('fk_child', $externalChildId->getIdString()); $dbc = Services::getService("DBHandler"); $dbc->query($query, $this->_configuration->getProperty('database_index')); }
/** * Save an XML string to the feed cache * * @param string $url * @param string $feedXml * @return void * @access protected * @since 7/8/08 */ protected function cacheXmlString($url, $feedXml) { $dbc = Services::getService("DatabaseManager"); $query = new DeleteQuery(); $query->setTable('segue_plugins_rssfeed_cache'); $query->addWhereEqual('url', $url); $query->addWhereRawLessThan('cache_time', $dbc->toDBDate(DateAndTime::now()->minus(Duration::withSeconds(600)), IMPORTER_CONNECTION), _OR); try { $result = $dbc->query($query, IMPORTER_CONNECTION); } catch (NoSuchTableDatabaseException $e) { $this->createCacheTable(); } $query = new InsertQuery(); $query->setTable('segue_plugins_rssfeed_cache'); $query->addValue('url', $url); $query->addValue('feed_data', $feedXml); $dbc->query($query, IMPORTER_CONNECTION); }
/** * Delete a Hierarchy by unique Id. All Nodes must be removed from the * Hierarchy before this method is called. * * @param object Id $hierarchyId * * @throws object HierarchyException An exception with one of * the following messages defined in * org.osid.hierarchy.HierarchyException may be thrown: {@link * org.osid.hierarchy.HierarchyException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.hierarchy.HierarchyException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.hierarchy.HierarchyException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.hierarchy.HierarchyException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.hierarchy.HierarchyException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.hierarchy.HierarchyException#NODE_TYPE_NOT_FOUND * NODE_TYPE_NOT_FOUND}, {@link * org.osid.hierarchy.HierarchyException#HIERARCHY_NOT_EMPTY * HIERARCHY_NOT_EMPTY} * * @access public */ function deleteHierarchy(Id $hierarchyId) { // ** parameter validation ArgumentValidator::validate($hierarchyId, ExtendsValidatorRule::getRule("Id"), true); // ** end of parameter validation $dbHandler = Services::getService("DatabaseManager"); $idValue = $hierarchyId->getIdString(); // see if there are any nodes remaining that have to removed $query = new SelectQuery(); $query->addTable("az2_node"); $query->addColumn("COUNT(az2_node.id)", "num"); $query->addWhereEqual("fk_hierarchy", $idValue); $queryResult = $dbHandler->query($query, $this->_dbIndex); $row = $queryResult->getCurrentRow(); $queryResult->free(); // if the hierarchy contains any nodes, cannot delete if ($row['num'] > 0) { throw new OperationFailedException("Hierarchy not empty."); return; } // now delete it $query = new DeleteQuery(); $query->setTable("az2_hierarchy"); $query->addWhereEqual("id", $idValue); $queryResult = $dbHandler->query($query, $this->_dbIndex); if ($queryResult->getNumberOfRows() != 1) { throw new OperationFailedException("Wrong number of rows deleted. Expecting 1."); } // update the cache $this->_hierarchies[$idValue] = null; unset($this->_hierarchies[$idValue]); }
/** * Clear the ancestory rows for a given node * * @param string $idString * @return void * @access public * @since 11/4/05 */ function clearNodeAncestory($idString) { // Delete the old ancestory if (isset($this->harmoni_db)) { if (!isset($this->clearNodeAncestory_stmt)) { $query = $this->harmoni_db->delete(); $query->setTable("az2_node_ancestry"); $query->addWhereRawEqual("fk_hierarchy", '?'); $query->addWhereRawEqual("fk_node", '?'); $this->clearNodeAncestory_stmt = $query->prepare(); } $this->clearNodeAncestory_stmt->bindValue(1, $this->_hierarchyId); $this->clearNodeAncestory_stmt->bindValue(2, $idString); $this->clearNodeAncestory_stmt->execute(); } else { $dbHandler = Services::getService("DatabaseManager"); $query = new DeleteQuery(); $query->setTable("az2_node_ancestry"); $query->addWhereEqual("fk_hierarchy", $this->_hierarchyId); $query->addWhereEqual("fk_node", $idString); $queryResult = $dbHandler->query($query, $this->_dbIndex); } }
/** * Delete a slot * * @param string $shortname * @return void * @access public * @since 12/5/07 */ public function deleteSlot($shortname) { $slot = $this->getSlotByShortname($shortname); if ($slot->siteExists()) { throw new PermissionDeniedException("Cannot delete a slot for an existing site."); } $query = new DeleteQuery(); $query->setTable('segue_slot'); $query->addWhereEqual('shortname', $shortname); $dbc = Services::getService('DBHandler'); $result = $dbc->query($query, IMPORTER_CONNECTION); $query = new DeleteQuery(); $query->setTable('segue_slot_owner'); $query->addWhereEqual('shortname', $shortname); $dbc = Services::getService('DBHandler'); $result = $dbc->query($query, IMPORTER_CONNECTION); unset($this->slots[$shortname]); }
/** * Delete a Repository. * * @param object Id $repositoryId * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID} * * @access public */ function deleteRepository(Id $repositoryId) { $repository = $this->getRepository($repositoryId); // Check to see if this DR has any assets. $assets = $repository->getAssets(); // If so, delete them. if ($assets->hasNext()) { // We need to delete the assets by deleting the root assets $hasRootSearch = FALSE; $rootSearchType = new HarmoniType("Repository", "edu.middlebury.harmoni", "RootAssets", ""); $searchTypes = $repository->getSearchTypes(); while ($searchTypes->hasNext()) { if ($rootSearchType->isEqual($searchTypes->next())) { $hasRootSearch = TRUE; break; } } if ($hasRootSearch) { $criteria = NULL; $rootAssets = $repository->getAssetsBySearch($criteria, $rootSearchType, new HarmoniProperties(new Type('Repository', 'edu.middlebury', 'null'))); while ($rootAssets->hasNext()) { $asset = $rootAssets->next(); $repository->deleteAsset($asset->getId()); } } else { // if we cant then sort the asset ids by depth $infoIterator = $this->_hierarchy->traverse($repositoryId, Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_DOWN, Hierarchy::TRAVERSE_LEVELS_ALL); $levels = array(); while ($infoIterator->hasNextTraversalInfo()) { $info = $infoIterator->nextTraversalInfo(); if (!is_array($levels[$info->getLevel()])) { $levels[$info->getLevel()] = array(); } $levels[$info->getLevel()][] = $info->getNodeId(); } for ($i = count($levels) - 1; $i > 0; $i--) { $level = $levels[$i]; foreach (array_keys($level) as $key) { $repository->deleteAsset($level[$key]); } } } } // Delete the node for the DR $this->_hierarchy->deleteNode($repositoryId); // Delete type type for the Repository $query = new DeleteQuery(); $query->setTable("dr_repository_type"); $query->addWhereEqual("repository_id", $repositoryId->getIdString()); $dbc = Services::getService("DatabaseManager"); $dbc->query($query, $this->_dbIndex); unset($this->_createdRepositories[$repositoryId->getIdString()]); }
/** * Deletes the given Authorization. * @access public * @param ref object authorization The Authorization to delete. **/ function deleteFunction($functionId) { // ** parameter validation ArgumentValidator::validate($functionId, ExtendsValidatorRule::getRule("Id"), true); // ** end of parameter validation // get the id $idValue = $functionId->getIdString(); // now remove from database $dbHandler = Services::getService("DatabaseManager"); $query = new DeleteQuery(); $query->setTable("az_function"); $query->addWhereEqual("function_id", $idValue); $queryResult = $dbHandler->query($query, $this->_dbIndex); if ($queryResult->getNumberOfRows() != 1) { $err = "Zero or more than one function were deleted (must have been exactly one)."; throwError(new Error($err, "authorizarion", true)); } // update cache $this->_functions[$idValue] = null; unset($this->_functions[$idValue]); }
/** * Clear the ancestory rows for a given node * * @param string $idString * @return void * @access public * @since 11/4/05 */ function clearNodeAncestory($idString) { $dbHandler = Services::getService("DatabaseManager"); // Delete the old ancestory $query = new DeleteQuery(); $query->setTable("node_ancestry"); $query->addWhereEqual("fk_hierarchy", $this->_hierarchyId); $query->addWhereEqual("fk_node", $idString); $queryResult = $dbHandler->query($query, $this->_dbIndex); // $queryResult->free(); }
/** * Delete a preference * * @param string $key * @return void * @access protected * @since 9/16/08 */ protected function _deletePref($key) { // Do not persist preferences for anonymous. if ($this->_getCurrentAgentId() == 'edu.middlebury.agents.anonymous') { return; } $query = new DeleteQuery(); $query->setTable('user_prefs'); $query->addWhereEqual('agent_id', $this->_getCurrentAgentId()); $query->addWhereEqual('pref_key', $key); $dbc = Services::getService('DatabaseManager'); $dbc->query($query); }