2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								"use strict" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-11-30 13:35:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								var  nconf  =  require ( 'nconf' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-22 15:54:02 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									fs  =  require ( 'fs' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-30 13:35:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									path  =  require ( 'path' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									winston  =  require ( 'winston' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-19 15:07:38 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									async  =  require ( 'async' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-30 13:35:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-12-02 21:20:55 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									db  =  require ( './../database' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-30 13:35:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									user  =  require ( './../user' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									groups  =  require ( '../groups' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									topics  =  require ( './../topics' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-25 16:39:27 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									pkg  =  require ( './../../package' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-30 13:35:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									categories  =  require ( './../categories' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									meta  =  require ( '../meta' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-08 13:12:52 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									plugins  =  require ( '../plugins' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-19 15:07:38 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									widgets  =  require ( '../widgets' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 00:33:10 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									image  =  require ( './../image' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-13 19:41:54 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									file  =  require ( './../file' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-09 13:29:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									Languages  =  require ( '../languages' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-29 18:10:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									events  =  require ( './../events' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-25 16:39:27 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									utils  =  require ( './../../public/src/utils' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									templates  =  require ( './../../public/src/templates' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-30 13:35:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								var  Admin  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-29 15:40:48 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Admin . isAdmin  =  function  ( req ,  res ,  next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									user . isAdministrator ( ( req . user  &&  req . user . uid )  ?  req . user . uid  :  0 ,  function  ( err ,  isAdmin )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( ! isAdmin )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											res . status ( 403 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											res . redirect ( '/403' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											next ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-07-11 14:32:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Admin . buildHeader  =  function  ( req ,  res ,  callback )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									var  custom _header  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										'plugins' :  [ ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										'authentication' :  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-26 16:05:59 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									user . getUserFields ( req . user . uid ,  [ 'username' ,  'userslug' ,  'picture' ] ,  function ( err ,  userData )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										plugins . fireHook ( 'filter:admin.header.build' ,  custom _header ,  function ( err ,  custom _header )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											callback ( err ,  templates [ 'admin/header' ] . parse ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												csrf :  res . locals . csrf _token , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												relative _path :  nconf . get ( 'relative_path' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												plugins :  custom _header . plugins , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												authentication :  custom _header . authentication , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												userpicture :  userData . picture , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												username :  userData . username , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												userslug :  userData . userslug , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												'cache-buster' :  meta . config [ 'cache-buster' ]  ?  'v='  +  meta . config [ 'cache-buster' ]  :  '' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												env :  process . env . NODE _ENV  ?  true  :  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-26 16:05:59 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								function  uploadImage ( filename ,  req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									function  done ( err ,  image )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										var  er ,  rs ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										fs . unlink ( req . files . userPhoto . path ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-26 16:05:59 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											er  =  { error :  err . message } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											return  res . send ( req . xhr  ?  er  :  JSON . stringify ( er ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-09 03:33:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										rs  =  { path :  image . url } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										res . send ( req . xhr  ?  rs  :  JSON . stringify ( rs ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if ( plugins . hasListeners ( 'filter:uploadImage' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										plugins . fireHook ( 'filter:uploadImage' ,  req . files . userPhoto ,  done ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										file . saveFileToLocal ( filename ,  req . files . userPhoto . path ,  done ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								module . exports  =  function ( app ,  middleware ,  controllers )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									app . all ( '/api/admin/*' ,  Admin . isAdmin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									app . all ( '/admin/*' ,  Admin . isAdmin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									app . get ( '/admin' ,  Admin . isAdmin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									( function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										var  routes  =  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											'categories/active' ,  'categories/disabled' ,  'users' ,  'topics' ,  'settings' ,  'themes' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											'database' ,  'events' ,  'motd' ,  'groups' ,  'plugins' ,  'languages' ,  'logger' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											'users/latest' ,  'users/sort-posts' ,  'users/sort-reputation' ,  'users/search' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										for  ( var  i  =  0 ,  ii  =  routes . length ;  i  <  ii ;  i ++ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											( function  ( route )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												app . get ( '/admin/'  +  route ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Admin . buildHeader ( req ,  res ,  function ( err ,  header )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														res . send ( header  +  app . create _route ( 'admin/'  +  route )  +  templates [ 'admin/footer' ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-13 13:34:15 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ( routes [ i ] ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									app . namespace ( '/admin' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 14:30:39 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/' ,  middleware . admin . buildHeader ,  function ( req ,  res ,  next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 13:17:10 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											res . render ( 'admin/index' ,  { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-09 03:33:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/index' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Admin . buildHeader ( req ,  res ,  function ( err ,  header )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . send ( header  +  app . create _route ( 'admin/index' )  +  templates [ 'admin/footer' ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 13:10:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-22 15:54:02 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . post ( '/category/uploadpicture' ,  function ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! req . user )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return  res . redirect ( '/403' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-08 13:12:52 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											var  allowedTypes  =  [ 'image/png' ,  'image/jpeg' ,  'image/jpg' ,  'image/gif' ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												params  =  null ,  er ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												params  =  JSON . parse ( req . body . params ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											}  catch  ( e )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												er  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													error :  'Error uploading file! Error :'  +  e . message 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return  res . send ( req . xhr  ?  er  :  JSON . stringify ( er ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-08 13:12:52 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( allowedTypes . indexOf ( req . files . userPhoto . type )  ===  - 1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												er  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													error :  'Allowed image types are png, jpg and gif!' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . send ( req . xhr  ?  er  :  JSON . stringify ( er ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-08 13:12:52 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											var  filename  =   'category-'  +  params . cid  +  path . extname ( req . files . userPhoto . name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-08 13:12:52 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											uploadImage ( filename ,  req ,  res ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-08 13:12:52 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . post ( '/uploadfavicon' ,  function ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											if  ( ! req . user )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return  res . redirect ( '/403' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-09 13:01:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											var  allowedTypes  =  [ 'image/x-icon' ,  'image/vnd.microsoft.icon' ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												er ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-09 13:01:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( allowedTypes . indexOf ( req . files . userPhoto . type )  ===  - 1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												er  =  { error :  'You can only upload icon file type!' } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . send ( req . xhr  ?  er  :  JSON . stringify ( er ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-09 13:01:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											file . saveFileToLocal ( 'favicon.ico' ,  req . files . userPhoto . path ,  function ( err ,  image )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												fs . unlink ( req . files . userPhoto . path ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-13 19:41:54 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													er  =  { error :  err . message } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													return  res . send ( req . xhr  ?  er  :  JSON . stringify ( er ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-09 00:33:10 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												var  rs  =  { path :  image . url } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . send ( req . xhr  ?  rs  :  JSON . stringify ( rs ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-09 13:01:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-09 13:01:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . post ( '/uploadlogo' ,  function ( req ,  res )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-22 15:54:02 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( ! req . user )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return  res . redirect ( '/403' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-22 15:54:02 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											var  allowedTypes  =  [ 'image/png' ,  'image/jpeg' ,  'image/pjpeg' ,  'image/jpg' ,  'image/gif' ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												er ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-22 15:54:02 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( allowedTypes . indexOf ( req . files . userPhoto . type )  ===  - 1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												er  =  { error :  'Allowed image types are png, jpg and gif!' } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . send ( req . xhr  ?  er  :  JSON . stringify ( er ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-22 15:54:02 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											var  filename  =  'site-logo'  +  path . extname ( req . files . userPhoto . name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-22 15:54:02 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											uploadImage ( filename ,  req ,  res ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-07 14:01:32 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/users/csv' ,  function ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											user . getUsersCSV ( function ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . attachment ( 'users.csv' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . setHeader ( 'Content-Type' ,  'text/csv' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . end ( data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-07 14:01:32 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-31 03:14:22 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-22 15:54:02 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									var  custom _routes  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										'routes' :  [ ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										'api' :  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									plugins . ready ( function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										plugins . fireHook ( 'filter:admin.create_routes' ,  custom _routes ,  function ( err ,  custom _routes )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											var  route ,  routes  =  custom _routes . routes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											for  ( route  in  routes )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( routes . hasOwnProperty ( route ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													( function ( route )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														app [ routes [ route ] . method  ||  'get' ] ( '/admin'  +  routes [ route ] . route ,  function ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															routes [ route ] . options ( req ,  res ,  function ( options )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																Admin . buildHeader ( req ,  res ,  function  ( err ,  header )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																	res . send ( header  +  options . content  +  templates [ 'admin/footer' ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-13 14:30:39 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
																} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} ( route ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-13 14:30:39 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-16 15:40:59 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											var  apiRoutes  =  custom _routes . api ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											for  ( route  in  apiRoutes )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( apiRoutes . hasOwnProperty ( route ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													( function ( route )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														app [ apiRoutes [ route ] . method  ||  'get' ] ( '/api/admin'  +  apiRoutes [ route ] . route ,  function ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															apiRoutes [ route ] . callback ( req ,  res ,  function ( data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
																res . json ( data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-16 15:40:59 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
															} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} ( route ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-16 15:40:59 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-13 14:30:39 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-13 14:30:39 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-11-28 22:29:32 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									app . namespace ( '/api/admin' ,  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-11-28 22:29:32 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/index' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											res . json ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												version :  pkg . version , 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/users/search' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											res . json ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												search _display :  'block' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												loadmore _display :  'none' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												users :  [ ] 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/users/latest' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											user . getUsers ( 'users:joindate' ,  0 ,  49 ,  function  ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . json ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													search _display :  'none' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													loadmore _display :  'block' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													users :  data , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													yourid :  req . user . uid 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 13:10:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/users/sort-posts' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											user . getUsers ( 'users:postcount' ,  0 ,  49 ,  function  ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . json ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													search _display :  'none' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													loadmore _display :  'block' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													users :  data , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													yourid :  req . user . uid 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 13:10:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/users/sort-reputation' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											user . getUsers ( 'users:reputation' ,  0 ,  49 ,  function  ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . json ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													search _display :  'none' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													loadmore _display :  'block' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													users :  data , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													yourid :  req . user . uid 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-24 14:18:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/users' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											user . getUsers ( 'users:joindate' ,  0 ,  49 ,  function  ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . json ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													search _display :  'none' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													users :  data , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													yourid :  req . user . uid 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-08 12:49:01 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-08 12:49:01 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/categories' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											categories . getAllCategories ( 0 ,  function  ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . json ( data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-08 12:49:01 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/categories/active' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											categories . getAllCategories ( 0 ,  function  ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												data . categories  =  data . categories . filter ( function  ( category )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													return  ! category . disabled ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												res . json ( data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/categories/disabled' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											categories . getAllCategories ( 0 ,  function  ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												data . categories  =  data . categories . filter ( function  ( category )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													return  category . disabled ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-24 14:18:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												res . json ( data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-24 14:18:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/topics' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											topics . getAllTopics ( 0 ,  19 ,  function  ( err ,  topics )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . json ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													topics :  topics , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													notopics :  topics . length  ===  0 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-24 14:18:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 13:10:14 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . namespace ( '/database' ,  function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											app . get ( '/' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												db . info ( function  ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													res . json ( data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-24 14:18:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-17 14:22:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/events' ,  function ( req ,  res ,  next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											events . getLog ( function ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													return  next ( err ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if ( data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													data  =  data . toString ( ) . split ( '\n' ) . reverse ( ) . join ( '\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . json ( 200 ,  { eventdata :  data } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-29 18:10:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-12-29 18:10:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/plugins' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											plugins . showInstalled ( function  ( err ,  plugins )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												if  ( err  ||  ! Array . isArray ( plugins ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													plugins  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												res . json ( 200 ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													plugins :  plugins 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-02 14:29:40 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-09 03:33:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/languages' ,  function ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Languages . list ( function ( err ,  languages )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												res . send ( 200 ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													languages :  languages 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-09 13:29:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-09 13:29:41 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/settings' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											res . json ( 200 ,  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-20 14:45:38 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/motd' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											res . json ( 200 ,  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-02 00:25:46 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/logger' ,  function ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											res . json ( 200 ,  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-20 17:58:12 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/themes' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											async . parallel ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												areas :  function ( next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													plugins . fireHook ( 'filter:widgets.getAreas' ,  [ ] ,  next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												widgets :  function ( next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													plugins . fireHook ( 'filter:widgets.getWidgets' ,  [ ] ,  next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ,  function ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												async . each ( data . areas ,  function ( area ,  next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													widgets . getArea ( area . template ,  area . location ,  function ( err ,  areaData )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														area . data  =  areaData ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														next ( err ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-19 11:43:25 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ,  function ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													for  ( var  w  in  data . widgets )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														if  ( data . widgets . hasOwnProperty ( w ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
															data . widgets [ w ] . content  +=  "<br /><label>Title:</label><input type=\"text\" class=\"form-control\" name=\"title\" placeholder=\"Title (only shown on some containers)\" /><br /><label>Container:</label><textarea rows=\"4\" class=\"form-control container-html\" name=\"container\" placeholder=\"Drag and drop a container or enter HTML here.\"></textarea>" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														} 
							 
						 
					
						
							
								
									
										
										
										
											2014-02-19 18:44:31 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-24 14:18:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													res . json ( 200 ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
														areas :  data . areas , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														widgets :  data . widgets 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-24 14:18:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-29 14:55:30 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-09 03:33:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										app . get ( '/groups' ,  function  ( req ,  res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											async . parallel ( [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												function ( next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													groups . list ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														expand :  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} ,  next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												function ( next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													groups . listSystemGroups ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														expand :  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} ,  next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											] ,  function ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												var 	groups  =  data [ 0 ] . concat ( data [ 1 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-09 03:33:53 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-03-03 12:50:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												res . json ( 200 ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													groups :  groups , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													yourid :  req . user . uid 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;