Skip to content

Commit ce54101

Browse files
committed
Initial import
1 parent 5fe7338 commit ce54101

11 files changed

Lines changed: 796 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!--- @@Copyright: Daemon Pty Limited 2002-2008, http://www.daemon.com.au --->
2+
<!--- @@License:
3+
This file is part of FarCry.
4+
5+
FarCry is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
FarCry is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with FarCry. If not, see <http://www.gnu.org/licenses/>.
17+
--->
18+
<!---
19+
|| DESCRIPTION ||
20+
$Description: Permission administration. $
21+
22+
|| DEVELOPER ||
23+
$Developer: Blair McKenzie (blair@daemon.com.au) $
24+
--->
25+
26+
<!--- import tag libraries --->
27+
<cfimport taglib="/farcry/core/tags/admin/" prefix="admin" />
28+
<cfimport taglib="/farcry/core/tags/formtools" prefix="ft" />
29+
30+
<!--- set up page header --->
31+
<admin:header title="Google Group Admin" />
32+
33+
<ft:objectadmin
34+
typename="gudGroup"
35+
title="Google Group Administration"
36+
columnList="title"
37+
sortableColumns="title"
38+
lFilterFields="title"
39+
sqlorderby="title asc"
40+
module="customlists/gudGroup.cfm"
41+
plugin="googleud" />
42+
43+
<admin:footer />

customadmin/webtop.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<webtop>
3+
<section id="admin" mergeType="merge">
4+
<subsection id="general">
5+
<menu id="farcryud" sequence="100" label="User Directory" permission="SecurityPolicyManagementTab">
6+
<menuitem id="listgudgroup" sequence="30" label="Google Groups" link="/admin/customadmin.cfm?module=customlists/gudGroup.cfm&amp;plugin=googleud" />
7+
</menu>
8+
</subsection>
9+
</section>
10+
</webtop>

packages/forms/configGUD.cfc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<cfcomponent displayname="Google User Directory" extends="farcry.core.packages.forms.forms" output="false" key="gud">
2+
3+
<cfproperty ftSeq="1" ftFieldset="Google Analytics API Access" ftLabel="Proxy"
4+
name="proxy" type="string"
5+
ftHint="If internet access is only available through a proxy, set here. Use the format '[username:password@]domain[:port]'."
6+
ftHelpSection="When you set up this config you will need to enter the redirect URL: http://[hostname]/index.cfm?type=gudLogin&view=displayLogin" />
7+
8+
<cfproperty ftSeq="2" ftFieldset="Google Analytics API Access" ftLabel="Client ID"
9+
name="clientID" type="string"
10+
ftHint="This should be copied exactly from the <a href='https://code.google.com/apis/console'>API Console</a>." />
11+
12+
<cfproperty ftSeq="3" ftFieldset="Google Analytics API Access" ftLabel="Client Secret"
13+
name="clientSecret" type="string"
14+
ftHint="This should be copied exactly from the <a href='https://code.google.com/apis/console'>API Console</a>." />
15+
16+
17+
</cfcomponent>

packages/forms/gudLogin.cfc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<cfcomponent displayname="Google User Directory Login" extends="farcry.core.packages.forms.forms">
2+
3+
</cfcomponent>

packages/security/GoogleUserDirectory.cfc

Lines changed: 336 additions & 0 deletions
Large diffs are not rendered by default.

packages/types/gudGroup.cfc

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<cfcomponent displayname="Google UD Group" extends="farcry.core.packages.types.types" output="false" bsystem="true" hint="Users can be assigned to any number of groups. Groups in turn are mapped to roles within the system which determine what a user has permission to do.">
2+
3+
<cfproperty ftSeq="1" ftFieldset="Google UD Group" ftLabel="Title"
4+
name="title" type="string" default=""
5+
hint="The title of this group" />
6+
7+
<cfproperty ftSeq="2" ftFieldset="Google UD Group" ftRenderType="custom" ftLabel="Domains"
8+
name="aDomains" type="array"
9+
ftHint="A list of domains (one per line) that should automatically be assigned this group. '*' for all users. Strict matching to the domain part of the user's email address" />
10+
11+
12+
<cffunction name="ftEditADomains" access="public" output="true" returntype="string" hint="his will return a string of formatted HTML text to enable the user to edit the data">
13+
<cfargument name="typename" required="true" type="string" hint="The name of the type that this field is part of.">
14+
<cfargument name="stObject" required="true" type="struct" hint="The object of the record that this field is part of.">
15+
<cfargument name="stMetadata" required="true" type="struct" hint="This is the metadata that is either setup as part of the type.cfc or overridden when calling ft:object by using the stMetadata argument.">
16+
<cfargument name="fieldname" required="true" type="string" hint="This is the name that will be used for the form field. It includes the prefix that will be used by ft:processform.">
17+
18+
<cfset var html = "" />
19+
<cfset var nl = "
20+
" />
21+
22+
<cfsavecontent variable="html">
23+
<cfoutput>
24+
<div class="multiField">
25+
<div id="#arguments.fieldname#DIV">
26+
<div class="blockLabel">
27+
<textarea name="#arguments.fieldname#" id="#arguments.fieldname#" class="textareaInput #arguments.stMetadata.ftclass#" style="#arguments.stMetadata.ftstyle#">#arraytolist(arguments.stMetadata.value,nl)#</textarea>
28+
</div>
29+
</div>
30+
</div>
31+
</cfoutput>
32+
</cfsavecontent>
33+
34+
<cfreturn html>
35+
</cffunction>
36+
37+
<cffunction name="ftValidateADomains" access="public" output="false" returntype="struct" hint="This will return a struct with bSuccess and stError">
38+
<cfargument name="stFieldPost" required="true" type="struct" hint="The fields that are relevent to this field type.It consists of value and stSupporting">
39+
<cfargument name="stMetadata" required="true" type="struct" hint="This is the metadata that is either setup as part of the type.cfc or overridden when calling ft:object by using the stMetadata argument.">
40+
41+
<cfset var stResult = structNew()>
42+
<cfset stResult.bSuccess = true>
43+
<cfset stResult.value = stFieldPost.Value>
44+
<cfset stResult.stError = StructNew()>
45+
46+
<!--- --------------------------- --->
47+
<!--- Perform any validation here --->
48+
<!--- --------------------------- --->
49+
<cfset stResult.value = listtoarray(arguments.stFieldPost.value,"#chr(10)##chr(13)#") />
50+
51+
<!--- ----------------- --->
52+
<!--- Return the Result --->
53+
<!--- ----------------- --->
54+
<cfreturn stResult>
55+
56+
</cffunction>
57+
58+
59+
60+
<cffunction name="getID" access="public" output="false" returntype="uuid" hint="Returns the objectid for the specified object (name can be the objectid or the title)">
61+
<cfargument name="name" type="string" required="true" hint="Pass in a role name and the objectid will be returned" />
62+
63+
<cfset var qItem = "" />
64+
65+
<cfif isvalid("uuid",arguments.name)>
66+
<cfreturn arguments.name />
67+
<cfelse>
68+
<cfquery datasource="#application.dsn#" name="qItem">
69+
select *
70+
from #application.dbOwner#gudGroup
71+
where lower(title)=<cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(arguments.name)#" />
72+
</cfquery>
73+
74+
<cfreturn qItem.objectid[1] />
75+
</cfif>
76+
</cffunction>
77+
78+
<cffunction name="delete" access="public" hint="Removes any corresponding entries in farUser" returntype="struct" output="false">
79+
<cfargument name="objectid" required="yes" type="UUID" hint="Object ID of the object being deleted">
80+
<cfargument name="user" type="string" required="true" hint="Username for object creator" default="">
81+
<cfargument name="auditNote" type="string" required="true" hint="Note for audit trail" default="">
82+
83+
<cfset var stUser = structnew() />
84+
<cfset var qUser = "" />
85+
<cfset var oUser = createObject("component", application.stcoapi["gudUser"].packagePath) />
86+
87+
<cfquery datasource="#application.dsn#" name="qUser">
88+
delete
89+
from #application.dbowner#gudUser_aGroups
90+
where data=<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.objectid#" />
91+
</cfquery>
92+
93+
<cfreturn super.delete(objectid=arguments.objectid,user=arguments.user,auditNote=arguments.auditNote) />
94+
</cffunction>
95+
96+
<cffunction name="afterSave" access="public" output="false" returntype="struct" hint="Processes new type content">
97+
<cfargument name="stProperties" type="struct" required="true" hint="The properties that have been saved" />
98+
99+
<cfset application.security.initCache() />
100+
101+
<cfreturn arguments.stProperties />
102+
</cffunction>
103+
104+
</cfcomponent>

packages/types/gudUser.cfc

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<cfcomponent displayname="GUD User" hint="User model for the Google User Directory." extends="farcry.core.packages.types.types" output="false" description="">
2+
3+
<cfproperty ftLabel="UserID"
4+
name="userid" type="string" default="" hint="The userid to use in FarCry"
5+
ftType="string" />
6+
7+
<cfproperty ftLabel="Refresh Token"
8+
name="refreshToken" type="string" default="" />
9+
10+
<cfproperty ftLabel="Provider Domain" ftType="string"
11+
name="providerDomain" type="string" default=""
12+
hint="The stripped email domain" />
13+
14+
<cfproperty ftLabel="Groups"
15+
name="aGroups" type="array" default=""
16+
ftType="array" ftJoin="gudGroup"
17+
hint="The groups this member is a member of" />
18+
19+
<cfproperty ftLabel="Groups"
20+
name="lGroups" type="longchar" default=""
21+
ftType="arrayList" ftArrayField="aGroups" ftJoin="farGroup"
22+
hint="The groups this member is a member of (list generated automatically)" />
23+
24+
25+
<cffunction name="addGroup" access="public" output="false" returntype="void" hint="Adds this user to a group">
26+
<cfargument name="user" type="string" required="true" hint="The user to add" />
27+
<cfargument name="group" type="string" required="true" hint="The group to add to" />
28+
29+
<cfset var stUser = structnew() />
30+
<cfset var stGroup = structnew() />
31+
<cfset var oGroup = createObject("component", application.stcoapi["gudGroup"].packagePath) />
32+
<cfset var i = 0 />
33+
34+
<!--- Get the user by objectid or userid --->
35+
<cfif isvalid("uuid",arguments.user)>
36+
<cfset stUser = getData(arguments.user) />
37+
<cfelse>
38+
<cfset stUser = getByUserID(arguments.user) />
39+
</cfif>
40+
41+
<cfif not isvalid("uuid",arguments.group)>
42+
<cfset arguments.group = oGroup.getID(arguments.group) />
43+
</cfif>
44+
45+
<!--- Check to see if they are already a member of the group --->
46+
<cfparam name="stUser.aGroups" default="#arraynew(1)#" />
47+
<cfif listfindnocase(arraytolist(stUser.aGroups),arguments.group)>
48+
<cfset arrayappend(stUser.aGroups,arguments.group) />
49+
<cfset setData(stProperties=stUser) />
50+
</cfif>
51+
</cffunction>
52+
53+
<cffunction name="removeGroup" access="public" output="false" returntype="void" hint="Removes this user from a group">
54+
<cfargument name="user" type="string" required="true" hint="The user to add" />
55+
<cfargument name="group" type="string" required="true" hint="The group to add to" />
56+
57+
<cfset var stUser = structnew() />
58+
<cfset var i = 0 />
59+
<cfset var oGroup = createObject("component", application.stcoapi["gudGroup"].packagePath) />
60+
61+
<!--- Get the user by objectid or userid --->
62+
<cfif isvalid("uuid",arguments.user)>
63+
<cfset stUser = getData(arguments.user) />
64+
<cfelse>
65+
<cfset stUser = getByUserID(arguments.user) />
66+
</cfif>
67+
68+
<cfif not isvalid("uuid",arguments.group)>
69+
<cfset arguments.group = oGroup.getID(arguments.group) />
70+
</cfif>
71+
72+
<!--- Check to see if they are a member of the group --->
73+
<cfparam name="stUser.aGroups" default="#arraynew(1)#" />
74+
<cfloop from="#arraylen(stUser.aGroups)#" to="1" index="i" step="-1">
75+
<cfif stUser.aGroups[i] eq arguments.group>
76+
<cfset arraydeleteat(stUser.aGroups,i) />
77+
</cfif>
78+
</cfloop>
79+
80+
<cfset setData(stProperties=stUser) />
81+
</cffunction>
82+
83+
<cffunction name="getByUserID" access="public" output="false" returntype="struct" hint="Returns the data struct for the specified user id">
84+
<cfargument name="userid" type="string" required="true" hint="The user id" />
85+
86+
<cfset var stResult = structnew() />
87+
<cfset var qUser = "" />
88+
89+
<cfquery datasource="#application.dsn#" name="qUser">
90+
select *
91+
from #application.dbowner#gudUser
92+
where lower(userid)=<cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(arguments.userid)#" />
93+
</cfquery>
94+
95+
<cfif qUser.recordcount>
96+
<cfset stResult = getData(qUser.objectid) />
97+
</cfif>
98+
99+
<cfreturn stResult />
100+
</cffunction>
101+
102+
</cfcomponent>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<cfsetting enablecfoutputonly="true" />
2+
<!--- @@displayname: Summary details (CLIENTUD) --->
3+
<!--- @@description: Farcry UD specific details --->
4+
5+
<cfsetting enablecfoutputonly="false" />
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<cfsetting enablecfoutputonly="true" />
2+
<!--- @@displayname: Summary options (CLIENTUD) --->
3+
<!--- @@description: Farcry UD specific options --->
4+
5+
<cfimport taglib="/farcry/core/tags/webskin" prefix="skin" />
6+
7+
<cfset stUser = createObject("component", application.stcoapi["farUser"].packagePath).getByUserID(listfirst(stObj.username,"_")) />
8+
9+
<cfoutput>
10+
<li>
11+
<small>
12+
<a href="https://www.google.com/settings/account">Google Account Settings</a>
13+
</small>
14+
</li>
15+
</cfoutput>
16+
17+
<cfsetting enablecfoutputonly="false" />

webskin/dmProfile/editGUDUser.cfm

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<cfsetting enablecfoutputonly="true" />
2+
<!--- @@displayname: Edit Profile --->
3+
<!--- @@description: Form for users editing their own profile --->
4+
5+
<!--- import tag libraries --->
6+
<cfimport taglib="/farcry/core/tags/formtools/" prefix="ft" />
7+
<cfimport taglib="/farcry/core/tags/webskin/" prefix="skin" />
8+
9+
<cfset oUser = application.fapi.getContentType(typename="gudUser") />
10+
11+
<!-----------------------------
12+
ACTION
13+
------------------------------>
14+
<ft:serverSideValidation />
15+
16+
<ft:processform action="Save" exit="true">
17+
<ft:processformobjects typename="gudUser" lArrayListGenerate="lgroups" />
18+
19+
<!--- track whether we have saved a farUser record--->
20+
<cfset savedUserID = lsavedobjectids />
21+
22+
<ft:processformobjects typename="dmProfile">
23+
24+
<!--- We only check the profile/faruser relationship if we saved a CLIENTUD user --->
25+
<cfif len(savedUserID)>
26+
<cfset stUser = oUser.getData(objectid=savedUserID) />
27+
28+
<!--- If the current username is not the same one we saved (ie. new user) --->
29+
<cfif stProperties.username NEQ "#stUser.objectid#_GUD"><!--- New user --->
30+
<cfset stProperties.username = "#stUser.objectid#_GUD" />
31+
<cfset stProperties.userdirectory = "GUD" />
32+
</cfif>
33+
</cfif>
34+
35+
</ft:processformobjects>
36+
</ft:processform>
37+
38+
<ft:processform action="Cancel" exit="true" />
39+
40+
<cfif stObj.userdirectory eq "GUD" or stObj.userdirectory eq "">
41+
42+
<cfset userID = application.factory.oUtils.listSlice(stObj.username,1,-2,"_") />
43+
<cfset stUser = oUser.getByUserID(userID) />
44+
45+
<cfelse>
46+
47+
<cfset stUser = structnew() />
48+
49+
</cfif>
50+
51+
<!-----------------------------
52+
VIEW
53+
------------------------------>
54+
<cfoutput>
55+
<h1>EDIT: #stObj.firstname# #stObj.lastname# (#stObj.userdirectory#)</h1>
56+
</cfoutput>
57+
58+
<ft:form>
59+
<ft:object objectid="#stObj.objectid#" typename="dmProfile" lfields="firstname,lastname,breceiveemail,emailaddress,phone,fax,position,department,locale,overviewHome" lhiddenFields="username,userdirectory" legend="User details" />
60+
61+
<cfset userID = application.factory.oUtils.listSlice(stObj.username,1,-2,"_") />
62+
<cfset stUser = oUser.getByUserID(userID) />
63+
64+
<cfif structIsEmpty(stUser) or stUser.userid eq "">
65+
<cfset stPropValues = structnew() />
66+
<cfset stPropValues.userdirectory = "GUD" />
67+
68+
<ft:object stObject="#stObj#" typename="gudUser" lfields="userid,providerDomain,aGroups" stPropValues="#stPropValues#" legend="Security" />
69+
<cfelse>
70+
<ft:object stObject="#stUser#" typename="gudUser" lfields="aGroups" legend="Security" />
71+
</cfif>
72+
73+
<ft:farcryButtonPanel>
74+
<ft:button value="Save" color="orange" />
75+
<ft:button value="Cancel" validate="false" />
76+
</ft:farcryButtonPanel>
77+
</ft:form>
78+
79+
<cfsetting enablecfoutputonly="false" />

0 commit comments

Comments
 (0)