Permalink
Browse files

add methdo getReadableGraphsUsingResource to Store

  • Loading branch information...
1 parent db3e673 commit 5f60401a640d898010d71a4b1b367e31e307fb3f @white-gecko white-gecko committed Jan 11, 2013
Showing with 35 additions and 0 deletions.
  1. +35 −0 library/Erfurt/Store.php
View
@@ -11,6 +11,7 @@
* @package Erfurt
* @author Philipp Frischmuth <pfrischmuth@googlemail.com>
* @author Norman Heino <norman.heino@gmail.com>
+ * @author Natanael Arndt <arndtn@gmail.com>
*/
class Erfurt_Store
@@ -1689,6 +1690,40 @@ public function getGraphsUsingResource($resourceUri, $useAc = true)
return $graphResult;
}
+ /**
+ * Returns a list of graph URIs, simmilar to getGraphsUsingResource but checks if it is
+ * readable.
+ *
+ * @param string $resourceUri
+ * @return array
+ */
+ public function getReadableGraphsUsingResource($resourceUri)
+ {
+ $result = $this->getGraphsUsingResource($resourceUri, false);
+
+ if ($result) {
+ // get source graph
+ $allowedGraphs = array();
+ $ac = Erfurt_App::getInstance()->getAc();
+ foreach ($result as $g) {
+ if ($ac->isModelAllowed('view', $g)) {
+ $allowedGraphs[] = $g;
+ }
+ }
+
+ if (count($allowedGraphs) > 0) {
+ return $allowedGraphs;
+ } else {
+ // We use the first matching graph. The user is redirected and the next request
+ // has to decide, whether user is allowed to view or not. (Workaround since there are problems
+ // with linkeddata and https).
+ return $result[0];
+ }
+ } else {
+ return null;
+ }
+ }
+
/**
* Returns a logo URL.
*

0 comments on commit 5f60401

Please sign in to comment.