'User Links' block is no longer hard coded
git-svn-id: file:///home/shish/svn/shimmie2/trunk@79 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
		
							parent
							
								
									ea9da95c7b
								
							
						
					
					
						commit
						c25427a5d1
					
				| @ -51,6 +51,12 @@ class AdminPage extends Extension { | |||||||
| 		if(is_a($event, 'AdminBuildingEvent')) { | 		if(is_a($event, 'AdminBuildingEvent')) { | ||||||
| 			$this->build_page(); | 			$this->build_page(); | ||||||
| 		} | 		} | ||||||
|  | 
 | ||||||
|  | 		if(is_a($event, 'UserBlockBuildingEvent')) { | ||||||
|  | 			if($event->user->is_admin()) { | ||||||
|  | 				$event->add_link("Board Admin", make_link("admin")); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| // }}}
 | // }}}
 | ||||||
| // block HTML {{{
 | // block HTML {{{
 | ||||||
|  | |||||||
| @ -166,6 +166,12 @@ class Setup extends Extension { | |||||||
| 			$event->config->set_string_from_post("theme"); | 			$event->config->set_string_from_post("theme"); | ||||||
| 			$event->config->set_int_from_post("anon_id"); | 			$event->config->set_int_from_post("anon_id"); | ||||||
| 		} | 		} | ||||||
|  | 
 | ||||||
|  | 		if(is_a($event, 'UserBlockBuildingEvent')) { | ||||||
|  | 			if($event->user->is_admin()) { | ||||||
|  | 				$event->add_link("Board Config", make_link("setup")); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| // }}}
 | // }}}
 | ||||||
| // HTML building {{{
 | // HTML building {{{
 | ||||||
|  | |||||||
| @ -1,5 +1,19 @@ | |||||||
| <?php | <?php | ||||||
| 
 | 
 | ||||||
|  | class UserBlockBuildingEvent extends Event { | ||||||
|  | 	var $parts = array(); | ||||||
|  | 	var $user = null; | ||||||
|  | 
 | ||||||
|  | 	public function UserBlockBuildingEvent($user) { | ||||||
|  | 		$this->user = $user; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public function add_link($name, $link, $position=50) { | ||||||
|  | 		while(isset($this->parts[$position])) $position++; | ||||||
|  | 		$this->parts[$position] = "<a href='$link'>$name</a>"; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| class UserPage extends Extension { | class UserPage extends Extension { | ||||||
| // event handling {{{
 | // event handling {{{
 | ||||||
| 	public function receive_event($event) { | 	public function receive_event($event) { | ||||||
| @ -66,6 +80,11 @@ class UserPage extends Extension { | |||||||
| 			$event->config->set_bool_from_post("login_signup_enabled"); | 			$event->config->set_bool_from_post("login_signup_enabled"); | ||||||
| 			$event->config->set_string_from_post("login_tac"); | 			$event->config->set_string_from_post("login_tac"); | ||||||
| 		} | 		} | ||||||
|  | 
 | ||||||
|  | 		if(is_a($event, 'UserBlockBuildingEvent')) { | ||||||
|  | 			$event->add_link("User Config", make_link("user")); | ||||||
|  | 			$event->add_link("Log Out", make_link("user/logout")); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| // }}}
 | // }}}
 | ||||||
| // Things done *with* the user {{{
 | // Things done *with* the user {{{
 | ||||||
| @ -361,14 +380,15 @@ class UserPage extends Extension { | |||||||
| 	private function build_links_block() { | 	private function build_links_block() { | ||||||
| 		global $user; | 		global $user; | ||||||
| 
 | 
 | ||||||
|  | 		$ubbe = new UserBlockBuildingEvent($user); | ||||||
|  | 
 | ||||||
|  | 		send_event($ubbe); | ||||||
|  | 
 | ||||||
| 		$h_name = html_escape($user->name); | 		$h_name = html_escape($user->name); | ||||||
| 		$html = "Logged in as $h_name"; | 		$html = "Logged in as $h_name<br>"; | ||||||
| 		if($user->is_admin()) { | 
 | ||||||
| 			$html .= "<br/><a href='".make_link("setup")."'>Board Config</a>"; | 		$html .= join("\n<br/>", $ubbe->parts); | ||||||
| 			$html .= "<br/><a href='".make_link("admin")."'>Admin</a>"; | 		 | ||||||
| 		} |  | ||||||
| 		$html .= "<br/><a href='".make_link("user")."'>User Config</a>"; |  | ||||||
| 		$html .= "<br/><a href='".make_link("user/logout")."'>Log Out</a>"; |  | ||||||
| 		return $html; | 		return $html; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user