Skip to content

Commit

Permalink
Making the navigation change require a domain so that it won't be abl…
Browse files Browse the repository at this point in the history
…e to remove navigation for a different domain.

Closes #102
  • Loading branch information
Zoramite committed Jul 9, 2011
1 parent fe97ad1 commit 4d2968b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
12 changes: 11 additions & 1 deletion content/extend/api/api/apiNavigation.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ component extends="plugins.api.inc.resource.base.api" {
var results = '';

servPath = variables.services.get('content', 'path');
servDomain = variables.services.get('content', 'domain');
servNavigation = variables.services.get('content', 'navigation');

// Get the domain
filter = {
host: variables.transport.theCgi.remote_host
};

local.domains = servDomain.getDomains(filter);

local.domain = servDomain.getDomain(local.domains.domainID.toString());

// Get the path
filter = {
path: arguments.path
Expand All @@ -20,7 +30,7 @@ component extends="plugins.api.inc.resource.base.api" {
currentPath = servPath.getPath(paths.pathID.toString());

// Save the positions of the navigation
servNavigation.setPositions(currentPath, arguments.positions);
servNavigation.setPositions(currentPath, local.domain, arguments.positions);

// Send back some of the request
variables.apiResponseHead['path'] = variables.apiRequestBody.path;
Expand Down
4 changes: 4 additions & 0 deletions content/inc/service/servDomain.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
)
</cfif>

<cfif structKeyExists(arguments.filter, 'host') and arguments.filter.host neq ''>
and h."hostname" = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.filter.host#" />
</cfif>

<cfif structKeyExists(arguments.filter, 'isArchived')>
and d."archivedOn" IS <cfif arguments.filter.isArchived>NOT</cfif> NULL
</cfif>
Expand Down
46 changes: 28 additions & 18 deletions content/inc/service/servNavigation.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@

<cffunction name="setPositions" access="public" returntype="void" output="false">
<cfargument name="path" type="component" required="true" />
<cfargument name="domain" type="component" required="true" />
<cfargument name="positions" type="array" required="true" />

<cfset var cleaned = '' />
Expand Down Expand Up @@ -210,14 +211,17 @@
WHERE
"pathID" IN (
<!--- Make sure all paths are directly off the base path, including wildcard paths --->
SELECT "pathID"
FROM "#variables.datasource.prefix#content"."path"
WHERE LOWER("path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%" />
SELECT p."pathID"
FROM "#variables.datasource.prefix#content"."path" p
JOIN "#variables.datasource.prefix#content"."content" c
ON p."contentID" = c."contentID"
AND c."domainID" = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.domain.getDomainID()#" />::uuid
WHERE LOWER(p."path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%" />
AND (
LOWER("path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%" />
LOWER(p."path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%" />
OR (
LOWER("path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/*" />
AND LOWER("path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%/*" />
LOWER(p."path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/*" />
AND LOWER(p."path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%/*" />
)
)
)
Expand Down Expand Up @@ -245,14 +249,17 @@
</cfif>
AND "pathID" IN (
<!--- Make sure all paths are directly off the base path, including wildcard paths --->
SELECT "pathID"
FROM "#variables.datasource.prefix#content"."path"
WHERE LOWER("path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%" />
SELECT p."pathID"
FROM "#variables.datasource.prefix#content"."path" p
JOIN "#variables.datasource.prefix#content"."content" c
ON p."contentID" = c."contentID"
AND c."domainID" = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.domain.getDomainID()#" />::uuid
WHERE LOWER(p."path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%" />
AND (
LOWER("path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%" />
LOWER(p."path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%" />
OR (
LOWER("path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/*" />
AND LOWER("path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%/*" />
LOWER(p."path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/*" />
AND LOWER(p."path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%/*" />
)
)
)
Expand Down Expand Up @@ -285,14 +292,17 @@
AND "pathID" = <cfqueryparam cfsqltype="cf_sql_varchar" value="#position.paths[i].pathID#" />::uuid
AND "pathID" IN (
<!--- Make sure all paths are directly off the base path, including wildcard paths --->
SELECT "pathID"
FROM "#variables.datasource.prefix#content"."path"
WHERE LOWER("path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%" />
SELECT p."pathID"
FROM "#variables.datasource.prefix#content"."path" p
JOIN "#variables.datasource.prefix#content"."content" c
ON p."contentID" = c."contentID"
AND c."domainID" = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.domain.getDomainID()#" />::uuid
WHERE LOWER(p."path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%" />
AND (
LOWER("path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%" />
LOWER(p."path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%" />
OR (
LOWER("path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/*" />
AND LOWER("path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%/*" />
LOWER(p."path") LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/*" />
AND LOWER(p."path") NOT LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="#lcase(cleaned)#%/%/*" />
)
)
)
Expand Down

0 comments on commit 4d2968b

Please sign in to comment.