Delete all publications

@param int $advertised search for advertised courses
@param int $shared search for shared courses
@throws moodle_exception
2167
public static function delete_all_publications($advertised = true, $shared = true) {
        global $DB;

        if (!$advertised && !$shared) {
            // Nothing to do.
            return true;
        }

        $params = ['huburl' => HUB_MOODLEORGHUBURL];
        if (!$advertised || !$shared) {
            // Retrieve ONLY advertised or ONLY shared.
            $params['enrollable'] = $advertised ? 1 : 0;
        }

        if (!$publications = $DB->get_records('course_published', $params)) {
            // Nothing to unpublish.
            return true;
        }

        foreach ($publications as $publication) {
            $hubcourseids[] = $publication->hubcourseid;
        }

        api::unregister_courses($hubcourseids);

        // Delete the published courses from local db.
        $DB->delete_records('course_published', $params);
        return true;
    }
1178794
public void deleteSearchFavourite(SearchFavourite sf) throws IOException {
		synchronized (lock) {
			if (sf == null || sf.getId() == null) {
				throw new IllegalArgumentException("null, or id not set!");
			} else {
				allFavourites.remove(sf.getId());
				if (sf.isShared()) {
					sharedFavourites.remove(sf.getId());
				} else {
					if (sf.getCreator() != null) {
						Map<Long, SearchFavourite> favs = privateFavourites.get(sf.getCreator());
						if (favs != null) {
							favs.remove(sf.getId());
						}
					} else {
						log.warn("Creator is not set! I'm not checking all users so I'm giving up.");
					}
				}
			}
		}
	}
10247
public function delete( $id = null, $attributes = array(), $search = false )
    {
        $this->forceStoreRegistry = true;
        parent::delete( $id, $attributes, $search );
    }
1195720
public static function delete($target, $include_target = true)
    {
        if (!is_dir($target)) {
            return false;
        }

        $success = self::doDelete($target, $include_target);

        if (!$success) {
            $error = error_get_last();
            throw new \RuntimeException($error['message']);
        }

        // Make sure that the change will be detected when caching.
        if ($include_target) {
            @touch(dirname($target));
        } else {
            @touch($target);
        }

        return $success;
    }
853119
public function RemoveArticleFromNoticeList($sArticleId)
    {
        $this->GetNoticeListArticles();
        if (array_key_exists($sArticleId, $this->aNoticeList)) {
            unset($this->aNoticeList[$sArticleId]);
            if ($this->IsLoggedIn()) {
                $noticeListItemObject = TdbShopUserNoticeList::GetNewInstance();
                if (true === $noticeListItemObject->LoadFromFields(
                    array(
                        'data_extranet_user_id' => $this->id,
                        'shop_article_id' => $sArticleId,
                    )
                )) {
                    $noticeListItemObject->Delete();
                }
            } else {
                $this->CommitNoticeListToCookie();
            }
        }
    }
532188
public function do_delete($topic)
    {
        /** @var \ManaPHP\DbInterface $db */
        $db = $this->_di->getShared($this->_db);

        $db->delete($this->_source, ['topic' => $topic]);
    }
622211
@Override
    public void setShareDurableSubscriptions(
                                             final String shareDurableSubscriptions) {
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
            SibTr.debug(this, TRACE, "shareDurableSubscriptions",
                        shareDurableSubscriptions);
        }
        _shareDurableSubscriptions = shareDurableSubscriptions;
    }
595290
public function purge($cascade = null, $use_transaction = false)
	{

		$this->_disable_soft_delete = true;
		$result = parent::delete($cascade, $use_transaction);
		$this->_disable_soft_delete = false;

		return $result;
	}
302579
public function delete()
	{
        if (!$this->isXmlHttpRequest()) {
            throw new common_exception_BadRequest('wrong request mode');
        } else {
			$deleted = false;
			if($this->getRequestParameter('uri')){

				$role = $this->getCurrentInstance();

				if(!in_array($role->getUri(), $this->forbidden)){
						//check if no user is using this role:
						$userClass = $this->getClass(GenerisRdf::CLASS_GENERIS_USER);
						$options = array('recursive' => true, 'like' => false);
						$filters = array(GenerisRdf::PROPERTY_USER_ROLES => $role->getUri());
						$users = $userClass->searchInstances($filters, $options);
						if(empty($users)){
							//delete role here:
							$deleted = $this->getClassService()->removeRole($role);
						}else{
							//set message error
							throw new UserErrorException(__('This role is still given to one or more users. Please remove the role to these users first.'));
						}
				}else{
					throw new UserErrorException($role->getLabel() . ' could not be deleted');
				}
			}

			$this->returnJson(array('deleted' => $deleted));
		}
	}
1061708
protected function removeAbstractAlias($searched): void
    {
        if (!isset($this->alias[$searched])) {
            return;
        }

        foreach ($this->abstractAlias as $abstract => $aliases) {
            foreach ($aliases as $index => $alias) {
                if ($alias === $searched) {
                    unset($this->abstractAlias[$abstract][$index]);
                }
            }
        }
    }
1151421
def delete(self, using=None):
        
        if self.is_alone:
            # The default way of operating is to trigger the deletion of the associated topic
            # only if the considered post is the only post embedded in the topic
            self.topic.delete()
        else:
            super(AbstractPost, self).delete(using)
            self.topic.update_trackers()
498373
public function bind($abstract, $concrete = null, $shared = false)
    {
        $this->app->bind($abstract, $concrete, $shared);
    }
216306
public function reject($notice) {
        global $USER, $DB;
        $user = $DB->get_record('user', array('id' => $this->properties->requester), '*', MUST_EXIST);
        $this->notify($user, $USER, 'courserequestrejected', get_string('courserejectsubject'), get_string('courserejectemail', 'moodle', $notice));
        $this->delete();
    }
1054363
public function Delete($DiscussionID, $Target = '') {
      $Discussion = $this->DiscussionModel->GetID($DiscussionID);
      
      if (!$Discussion)
         throw NotFoundException('Discussion');
      
      $this->Permission('Vanilla.Discussions.Delete', TRUE, 'Category', $Discussion->PermissionCategoryID);
      
      if ($this->Form->IsPostBack()) {
         if (!$this->DiscussionModel->Delete($DiscussionID))
            $this->Form->AddError('Failed to delete discussion');
         
         if ($this->Form->ErrorCount() == 0) {
            if ($this->_DeliveryType === DELIVERY_TYPE_ALL)
               Redirect($Target);

            if ($Target)
               $this->RedirectUrl = Url($Target);
            
            $this->JsonTarget(".Section-DiscussionList #Discussion_$DiscussionID", NULL, 'SlideUp');
         }
      }
      
      $this->SetData('Title', T('Delete Discussion'));
      $this->Render();         
   }
1060813
@Override
	public void removeByC_LtD_S(long CPDefinitionId, Date displayDate,
		int status) {
		for (CPInstance cpInstance : findByC_LtD_S(CPDefinitionId, displayDate,
				status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(cpInstance);
		}
	}
1211121
void releaseSharedSlot(SharedSlot sharedSlot) {
		synchronized (lock) {
			if (sharedSlot.markCancelled()) {
				// we are releasing this slot
				
				if (sharedSlot.hasChildren()) {
					final FlinkException cause = new FlinkException("Releasing shared slot parent.");
					// by simply releasing all children, we should eventually release this slot.
					Set<Slot> children = sharedSlot.getSubSlots();
					while (children.size() > 0) {
						children.iterator().next().releaseSlot(cause);
					}
				}
				else {
					// if there are no children that trigger the release, we trigger it directly
					internalDisposeEmptySharedSlot(sharedSlot);
				}
			}
		}
	}
3877
public function unsubscribe(array $topics)
    {
        foreach ($topics as $topic_filter) {
            $this->topics_to_unsubscribe[] = $topic_filter;
        }
        list($last_unsubscribe_msgid, $last_unsubscribe_topics) = $this->do_unsubscribe();
        $this->unsubscribe_awaits[$last_unsubscribe_msgid] = $last_unsubscribe_topics;
    }