mirror of
				https://github.com/ElvishArtisan/rivendell.git
				synced 2025-10-30 17:23:53 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			110 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			110 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // groups.cpp
 | |
| //
 | |
| // Rivendell web service portal -- Group services
 | |
| //
 | |
| //   (C) Copyright 2010-2018 Fred Gleason <fredg@paravelsystems.com>
 | |
| //
 | |
| //   This program is free software; you can redistribute it and/or modify
 | |
| //   it under the terms of the GNU General Public License version 2 as
 | |
| //   published by the Free Software Foundation.
 | |
| //
 | |
| //   This program is distributed in the hope that it will be useful,
 | |
| //   but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
| //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | |
| //   GNU General Public License for more details.
 | |
| //
 | |
| //   You should have received a copy of the GNU General Public
 | |
| //   License along with this program; if not, write to the Free Software
 | |
| //   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 | |
| //
 | |
| 
 | |
| #include <stdio.h>
 | |
| #include <sys/types.h>
 | |
| #include <sys/stat.h>
 | |
| #include <fcntl.h>
 | |
| #include <errno.h>
 | |
| 
 | |
| #include <rdapplication.h>
 | |
| #include <rdconf.h>
 | |
| #include <rdescape_string.h>
 | |
| #include <rdformpost.h>
 | |
| #include <rdgroup.h>
 | |
| #include <rduser.h>
 | |
| #include <rdweb.h>
 | |
| 
 | |
| #include "rdxport.h"
 | |
| 
 | |
| void Xport::ListGroups()
 | |
| {
 | |
|   QString sql;
 | |
|   RDSqlQuery *q;
 | |
|   RDGroup *group;
 | |
| 
 | |
|   //
 | |
|   // Generate Group List
 | |
|   //
 | |
|   sql=QString().sprintf("select GROUP_NAME from USER_PERMS \
 | |
|                          where USER_NAME=\"%s\" order by GROUP_NAME",
 | |
| 			(const char *)RDEscapeString(rda->user()->name()));
 | |
|   q=new RDSqlQuery(sql);
 | |
| 
 | |
|   //
 | |
|   // Process Request
 | |
|   //
 | |
|   printf("Content-type: application/xml\n");
 | |
|   printf("Status: 200\n\n");
 | |
|   printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
 | |
|   printf("<groupList>\n");
 | |
|   while(q->next()) {
 | |
|     group=new RDGroup(q->value(0).toString());
 | |
|     printf("%s",(const char *)group->xml());
 | |
|     delete group;
 | |
|   }
 | |
|   printf("</groupList>\n");
 | |
| 
 | |
|   delete q;
 | |
|   Exit(0);
 | |
| }
 | |
| 
 | |
| 
 | |
| void Xport::ListGroup()
 | |
| {
 | |
|   QString sql;
 | |
|   RDSqlQuery *q;
 | |
|   RDGroup *group;
 | |
| 
 | |
|   //
 | |
|   // Verify Post
 | |
|   //
 | |
|   QString group_name;
 | |
|   if(!xport_post->getValue("GROUP_NAME",&group_name)) {
 | |
|     XmlExit("Missing GROUP_NAME",400,"groups.cpp",LINE_NUMBER);
 | |
|   }
 | |
| 
 | |
|   //
 | |
|   // Check Group Accessibility
 | |
|   //
 | |
|   sql=QString().sprintf("select GROUP_NAME from USER_PERMS \
 | |
|                          where (USER_NAME=\"%s\")&&(GROUP_NAME=\"%s\")",
 | |
| 			(const char *)RDEscapeString(rda->user()->name()),
 | |
| 			(const char *)RDEscapeString(group_name));
 | |
|   q=new RDSqlQuery(sql);
 | |
|   if(!q->first()) {
 | |
|     delete q;
 | |
|     XmlExit("No such group",404,"groups.cpp",LINE_NUMBER);
 | |
|   }
 | |
| 
 | |
|   //
 | |
|   // Process Request
 | |
|   //
 | |
|   printf("Content-type: application/xml\n");
 | |
|   printf("Status: 200\n\n");
 | |
|   printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
 | |
|   group=new RDGroup(q->value(0).toString());
 | |
|   printf("%s",(const char *)group->xml());
 | |
|   delete group;
 | |
| 
 | |
|   delete q;
 | |
|   Exit(0);
 | |
| }
 |