<div dir="ltr">I'm developing a app for owncloud and I have a public page which is produced by a guest template. <br>From that page, I'm calling some functions of Filesystem namespace. But I'm getting an error. But when I tryed to load that page after logging in, then the error doesn't come. <br>
<br>Here is the function call and the definition of the function that I try to call from the above mentioned guest template page.<br><br><span style="font-family:arial,sans-serif;font-size:13px">$files = \OCA\CloudToCloud\</span><span style="font-family:arial,sans-serif;font-size:13px">CloudToCloudShare::getFiles($</span><span style="font-family:arial,sans-serif;font-size:13px">email,$dir);  // this is called from the 'public' page</span><br style="font-family:arial,sans-serif;font-size:13px">
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><div><br></div><div>    public static function getFiles($email,$dir){</div>
<div>        $query = \OC_DB::prepare("SELECT * FROM *PREFIX*c2c_share WHERE `email`=? ORDER BY `stime`");</div><div>        $result = $query->execute(array($email));</div><div>        $files = array();</div>
<div><br></div><div>        if($dir == ""){</div><div>            while ($aFile = $result->fetchRow()) {</div><div>                if($aFile['item_type'] == "file"){</div><div>                   $name = $aFile['file_target'];</div>
<div>                   $path = \OC\Files\Filesystem::getPath($aFile['item_source']);</div><div>                   $parent_path = substr($path,0,strrpos($path,'/')+1);</div><div>                   $dir_content = \OC\Files\Filesystem::getDirectoryContent($parent_path);</div>
<div><br></div><div>                    foreach($dir_content as $i){</div><div>                        if($i['name'] == $name && $i['type']=="file"){</div><div>                            $files[] = $i;</div>
<div>                            break;</div><div>                        }</div><div>                    }</div><div>                }else{</div><div>                    $name = $aFile['file_target'];</div><div>                    $path = \OC\Files\Filesystem::getPath($aFile['item_source']);</div>
<div>                    $parent_path = substr($path,0,strrpos($path,'/')+1);</div><div>                    $dir_content = \OC\Files\Filesystem::getDirectoryContent($parent_path);</div><div>                    foreach($dir_content as $i){</div>
<div>                        if($i['name'] == $name && $i['type']=="dir"){</div><div>                            $files[] = $i;</div><div>                            break;</div><div>                        }</div>
<div>                    }</div><div>                }</div><div>            }</div><div>        }else{</div><div>            while($aFile = $result->fetchRow()){</div><div>                if($aFile['item_type'] == "dir" && $aFile['file_target'] == $dir){</div>
<div>                    $path = \OC\Files\Filesystem::getPath($aFile['item_source']);</div><div>                    $dir_content = \OC\Files\Filesystem::getDirectoryContent($path);</div><div>                    foreach($dir_content as $i){</div>
<div>                            $files[] = $i;</div><div>                    }</div><div>                }</div><div>            }</div><div><br></div><div>        }</div><div>        return $files;</div><div>    }</div>
<div><br></div><div style>Please help me to resolve this error. <br>Thank YOu</div></div><br></div>