Exemplo n.º 1
0
	function delete($ids,&$results) {
		//check if user is owner of topic
		$select = "topic_id IN (".join(",",$ids).") AND user_id=$this->userId";
		
		if(!$rightRecords = $this->db->getRecords(MediabirdConfig::tableName("Right",true),$select)) {
			return MediabirdConstants::accessDenied;
		}
		else {
			foreach($rightRecords as $rightRecord) {
				if($rightRecord->mask < MediabirdTopicAccessConstants::owner) {
					return MediabirdConstants::accessDenied;
				}
			}
		}
		
		$okay = true;
		
		//now collect affected ids
		$select = "marker_id = ANY
			(SELECT id FROM ".MediabirdConfig::tableName('Marker')." WHERE topic_id IN (".join(",",$ids)."))";
		$okay = $okay && parent::deleteGeneric('Relation',$select,$results);
		
		$select = "card_id = ANY
			(SELECT id FROM ".MediabirdConfig::tableName('Card')." WHERE topic_id IN (".join(",",$ids)."))";
		$okay = $okay && parent::deleteGeneric('CardTag',$select);
		
		$select = "topic_id IN (".join(",",$ids).")";
		$okay = $okay && parent::deleteGeneric('Marker',$select,$results);
		
		$select = "topic_id IN (".join(",",$ids).")";
		$okay = $okay && parent::deleteGeneric('Card',$select,$results);
		
		$select = "topic_id IN (".join(",",$ids).")";
		$okay = $okay && parent::deleteGeneric('CardContent',$select);
		
		$select = "topic_id IN (".join(",",$ids).")";
		$okay = $okay && parent::deleteGeneric('Right',$select,$results);
		
		$select = "id IN (".join(",",$ids).")";
		$okay = $okay && parent::deleteGeneric('Topic',$select,$results);
		
		if($okay) {
			return MediabirdConstants::processed;	
		}
		else {
			return MediabirdConstants::serverError;
		}
	}
Exemplo n.º 2
0
	function delete($ids,&$results) {
		//check if user is owner of upload
		$select = "id IN (".join(",",$ids).") AND user_id=$this->userId";

		if($this->db->countRecords(MediabirdConfig::tableName("Upload",true),$select) != count($ids)) {
			return MediabirdConstants::accessDenied;
		}

		//now delete upload and cards featuring that file

		//detemine all cards that feature the file
		$select = "content_type=1 AND content_id IN (".join(",",$ids).")";

		$okay = true;

		if($cardRecords = $this->db->getRecords(MediabirdConfig::tableName("Card",true),$select)) {

			//collect their ids
			$cardIds = array();
			foreach($cardRecords as $cardRecord) {
				$cardIds []= intval($cardRecord->id);
			}

			$results['removedCardIds'] = $cardIds;

			//prepare delete statements
			$cardIdString = join(",",$cardIds);

			$select = "marker_id IN
				(SELECT id FROM ".MediabirdConfig::tableName('Marker')." WHERE card_id IN ($cardIdString))";
			$okay = $okay && parent::deleteGeneric('Relation',$select,$results);

			$select = "card_id IN ($cardIdString)";
			$okay = $okay && parent::deleteGeneric('CardTag',$select);

			$select = "card_id IN ($cardIdString)";
			$okay = $okay && parent::deleteGeneric('Marker',$select,$results);

			$select = "id IN ($cardIdString)";
			$okay = $okay && parent::deleteGeneric('Card',$select,$results);
		}

		$select = "id IN (".join(",",$ids).")";
		$okay = $okay && parent::deleteGeneric('Upload',$select,$results);

		if($okay) {
			return MediabirdConstants::processed;
		}
		else {
			return MediabirdConstants::serverError;
		}
	}