42 private $copyrightDao;
44 private $includeContainer = FALSE;
45 private $excludingCopyright = -1;
46 private $includingCopyright = -1;
51 function __construct()
54 $this->
dbManager = $container->get(
'db.manager');
55 $this->uploadDao = $container->get(
'dao.upload');
56 $this->treeDao = $container->get(
'dao.tree');
57 $this->copyrightDao = $container->get(
'dao.copyright');
60 public function setContainerInclusion($includeContainer)
62 $this->includeContainer = $includeContainer;
65 public function setExcludingCopyright($excludingCopyright)
67 $this->excludingCopyright = $excludingCopyright;
70 public function setIncludingCopyright($includingCopyright)
72 $this->includingCopyright = $includingCopyright;
75 public function setType($type)
87 $itemId = $this->uploadDao->getUploadParent($uploadId);
90 echo
'no valid copyright agent found';
93 $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($uploadId);
94 $toprow = $this->uploadDao->getItemTreeBounds($itemId,$uploadtree_tablename);
96 $extraWhere =
'agent_fk='.$this->agentId.
' AND lft>'.$toprow->getLeft().
' AND rgt<'.$toprow->getRight();
97 $allCopyrightEntries = $this->copyrightDao->getAllEntries(
'copyright', $uploadId, $uploadtree_tablename,
98 empty($this->type)||$this->type==
'all' ? null : $this->type,
false, null, $extraWhere);
100 $modeMask = empty($this->includeContainer) ? (3<<28) : (1<<28);
101 $sql =
"SELECT uploadtree_pk, ufile_name, lft, rgt FROM $uploadtree_tablename 102 WHERE upload_fk=$1 AND lft>$2 AND rgt<$3 AND (ufile_mode & $4) = 0 103 ORDER BY uploadtree_pk";
104 $this->
dbManager->prepare($outerStmt=__METHOD__.
'.loopThroughAllRecordsInTree',$sql);
105 $outerresult = $this->
dbManager->execute($outerStmt,array($toprow->getUploadId(),$toprow->getLeft(),$toprow->getRight(),$modeMask));
106 while ($row = $this->
dbManager->fetchArray($outerresult)) {
107 $this->
printRow($row,$uploadtree_tablename, $allCopyrightEntries);
109 $this->
dbManager->freeResult($outerresult);
120 $agentDao = $container->get(
'dao.agent');
121 $agentRec = $agentDao->agentARSList($tableName=
"copyright_ars", $uploadId, 1);
123 if ($agentRec ===
false) {
124 echo _(
"No data available \n");
127 $this->agentId = $agentRec[0][
"agent_fk"];
134 private function printRow($row,$uploadtree_tablename, &$allCopyrightEntries, $parentId=0)
136 $filepath = $this->treeDao->getFullPath($row[
'uploadtree_pk'], $uploadtree_tablename, $parentId);
138 $copyrightArray = array();
139 foreach ($allCopyrightEntries as $entry) {
140 if ($entry[
'uploadtree_pk'] == $row[
'uploadtree_pk']) {
141 $copyrightArray[] = $entry[
'content'];
144 $copyright = implode(
', ', $copyrightArray);
147 if (-1 != $this->includingCopyright && -1 != $this->excludingCopyright && !empty($this->includingCopyright) &&
148 !empty($this->excludingCopyright)) {
149 if (empty($copyright) || stristr($copyright, $this->includingCopyright) ||
150 stristr($copyright, $this->excludingCopyright)) {
155 ! (-1 == $this->includingCopyright && -1 == $this->excludingCopyright) &&
157 ! (empty($this->includingCopyright) && empty($this->excludingCopyright)) &&
159 ! (empty($this->includingCopyright) && empty($copyright)) &&
161 ! (empty($this->excludingCopyright) && !empty($copyright)) &&
163 ! (-1 != $this->includingCopyright && !empty($this->includingCopyright) && !empty($copyright) && stristr($copyright, $this->includingCopyright)) &&
165 ! (-1 != $this->excludingCopyright && !empty($this->excludingCopyright) && !empty($copyright) && !stristr($copyright, $this->excludingCopyright))) {
168 print (
"$filepath: $copyright\n");
getCopyrightList($itemId, $uploadId)
fo_dbManager * dbManager
fo_dbManager object
printRow($row, $uploadtree_tablename, &$allCopyrightEntries, $parentId=0)
write out text in format 'filepath: copyright list'