Merge pull request #546 from DakuTree/fix-relationships
Fix relationships ext checking for TRUE/FALSE instead of Y/N
This commit is contained in:
		
						commit
						8326ef631f
					
				| @ -67,7 +67,7 @@ class BaseThemelet { | ||||
| 		$custom_classes = ""; | ||||
| 		if(class_exists("Relationships")){ | ||||
| 			if(property_exists($image, 'parent_id') && $image->parent_id !== NULL){	$custom_classes .= "shm-thumb-has_parent ";	} | ||||
| 			if(property_exists($image, 'has_children') && $image->has_children == TRUE){ $custom_classes .= "shm-thumb-has_child "; } | ||||
| 			if(property_exists($image, 'has_children') && bool_escape($image->has_children)){ $custom_classes .= "shm-thumb-has_child "; } | ||||
| 		} | ||||
| 
 | ||||
| 		return "<a href='$h_view_link' class='thumb shm-thumb shm-thumb-link {$custom_classes}' data-tags='$h_tags' data-post-id='$i_id'>". | ||||
|  | ||||
| @ -21,11 +21,17 @@ class Relationships extends Extension { | ||||
| 			$config->set_int("ext_relationships_version", 1); | ||||
| 			log_info("relationships", "extension installed"); | ||||
| 		} | ||||
| 		if ($config->get_int("ext_relationships_version") < 2){ | ||||
| 			$database->execute("CREATE INDEX images__has_children ON images(has_children)"); | ||||
| 
 | ||||
| 			$config->set_int("ext_relationships_version", 2); | ||||
| 			log_info("relationships", "extension updated"); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	public function onImageInfoSet(ImageInfoSetEvent $event) { | ||||
| 		if(isset($_POST['tag_edit__tags']) ? !preg_match('/parent[=|:]/', $_POST["tag_edit__tags"]) : TRUE) { //Ignore tag_edit__parent if tags contain parent metatag
 | ||||
| 			if (isset($_POST["tag_edit__parent"]) ? ctype_digit($_POST["tag_edit__parent"]) : FALSE) { | ||||
| 			if(isset($_POST["tag_edit__parent"]) ? ctype_digit($_POST["tag_edit__parent"]) : FALSE) { | ||||
| 				$this->set_parent($event->image->id, (int) $_POST["tag_edit__parent"]); | ||||
| 			}else{ | ||||
| 				$this->remove_parent($event->image->id); | ||||
| @ -83,7 +89,7 @@ class Relationships extends Extension { | ||||
| 	public function onImageDeletion(ImageDeletionEvent $event) { | ||||
| 		global $database; | ||||
| 
 | ||||
| 		if($event->image->has_children){ | ||||
| 		if(bool_escape($event->image->has_children)){ | ||||
| 			$database->execute("UPDATE images SET parent_id = NULL WHERE parent_id = :iid", array("iid"=>$event->image->id)); | ||||
| 		} | ||||
| 
 | ||||
|  | ||||
| @ -12,7 +12,7 @@ class RelationshipsTheme extends Themelet { | ||||
| 			$page->add_block(new Block(null, "This post belongs to a $a.", "main", 5)); | ||||
| 		} | ||||
| 
 | ||||
| 		if($image->has_children == TRUE){ | ||||
| 		if(bool_escape($image->has_children)){ | ||||
| 			$ids = $database->get_col("SELECT id FROM images WHERE parent_id = :iid", array("iid"=>$image->id)); | ||||
| 
 | ||||
| 			$html = "This post has <a href='".make_link('post/list/parent='.$image->id.'/1')."'>".(count($ids) > 1 ? "child posts" : "a child post")."</a>"; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user