示例#1
0
 /**
  * \brief This function returns the scheduler status.
  */
 public function Output()
 {
     $uTime = microtime(true);
     $V = "";
     $Upload = GetParm("upload", PARM_INTEGER);
     /** @var UploadDao $uploadDao */
     $uploadDao = $GLOBALS['container']->get('dao.upload');
     if (!$uploadDao->isAccessible($Upload, Auth::getGroupId())) {
         $text = _("Permission Denied");
         return "<h2>{$text}</h2>";
     }
     $Item = GetParm("item", PARM_INTEGER);
     if (!$Item) {
         return _('No item selected');
     }
     $updcache = GetParm("updcache", PARM_INTEGER);
     $tagbucket = GetParm("tagbucket", PARM_INTEGER);
     $this->uploadtree_tablename = GetUploadtreeTableName($Upload);
     /* Remove "updcache" from the GET args and set $this->UpdCache
      * This way all the url's based on the input args won't be
      * polluted with updcache
      * Use Traceback_parm_keep to ensure that all parameters are in order 
      */
     $CacheKey = "?mod=" . $this->Name . Traceback_parm_keep(array("upload", "item", "folder", "ars"));
     if ($updcache) {
         $_SERVER['REQUEST_URI'] = preg_replace("/&updcache=[0-9]*/", "", $_SERVER['REQUEST_URI']);
         unset($_GET['updcache']);
         $V = ReportCachePurgeByKey($CacheKey);
     } else {
         $V = ReportCacheGet($CacheKey);
     }
     if (!empty($tagbucket)) {
         $bucketagent_pk = GetParm("bapk", PARM_INTEGER);
         $bucket_pk = GetParm("bpk", PARM_INTEGER);
         $bucketpool_pk = GetParm("bp", PARM_INTEGER);
         $nomosagent_pk = GetParm("napk", PARM_INTEGER);
         $this->TagBucket($Upload, $Item, $bucketagent_pk, $bucket_pk, $bucketpool_pk, $nomosagent_pk);
     }
     $Cached = !empty($V);
     if (!$Cached) {
         $V .= "<font class='text'>\n";
         $Children = GetNonArtifactChildren($Item, $this->uploadtree_tablename);
         if (count($Children) == 0) {
             // no children, display View-Meta micromenu
             $V .= Dir2Browse($this->Name, $Item, NULL, 1, "View-Meta", -1, '', '', $this->uploadtree_tablename) . "<P />\n";
         } else {
             // has children, display Browse micormenu
             $V .= Dir2Browse($this->Name, $Item, NULL, 1, "Browse", -1, '', '', $this->uploadtree_tablename) . "<P />\n";
         }
         if (!empty($Upload)) {
             $Uri = preg_replace("/&item=([0-9]*)/", "", Traceback());
             $V .= $this->ShowUploadHist($Item, $Uri);
         }
         $V .= "</font>\n";
         $text = _("Loading...");
     }
     $Time = microtime(true) - $uTime;
     // convert usecs to secs
     $text = _("Elapsed time: %.2f seconds");
     $V .= sprintf("<p><small>{$text}</small>", $Time);
     if ($Cached) {
         $text = _("cached");
         $text1 = _("Update");
         echo " <i>{$text}</i>   <a href=\"{$_SERVER['REQUEST_URI']}&updcache=1\"> {$text1} </a>";
     } else {
         if ($Time > 0.5) {
             ReportCachePut($CacheKey, $V);
         }
     }
     return $V;
 }
示例#2
0
 /**
  * \brief This function returns the scheduler status.
  */
 function Output()
 {
     $uTime = microtime(true);
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $V = "";
     $Folder = GetParm("folder", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     $Item = GetParm("item", PARM_INTEGER);
     switch (GetParm("show", PARM_STRING)) {
         case 'detail':
             $Show = 'detail';
             break;
         case 'summary':
         default:
             $Show = 'summary';
             break;
     }
     /* Use Traceback_parm_keep to ensure that all parameters are in order */
     $CacheKey = "?mod=" . $this->Name . Traceback_parm_keep(array("upload", "item", "folder")) . "&show={$Show}";
     if ($this->UpdCache != 0) {
         $V = "";
         $Err = ReportCachePurgeByKey($CacheKey);
     } else {
         $V = ReportCacheGet($CacheKey);
     }
     if (empty($V)) {
         switch ($this->OutputType) {
             case "XML":
                 break;
             case "HTML":
                 $V .= "<font class='text'>\n";
                 /************************/
                 /* Show the folder path */
                 /************************/
                 $V .= Dir2Browse($this->Name, $Item, NULL, 1, "Browse") . "<P />\n";
                 /******************************/
                 /* Get the folder description */
                 /******************************/
                 if (!empty($Folder)) {
                     // $V .= $this->ShowFolder($Folder);
                 }
                 if (!empty($Upload)) {
                     $Uri = preg_replace("/&item=([0-9]*)/", "", Traceback());
                     $V .= $this->ShowUploadHist($Upload, $Item, $Uri);
                 }
                 $V .= "</font>\n";
                 break;
             case "Text":
                 break;
             default:
                 break;
         }
         $Cached = false;
         /*  Cache Report if this took longer than 1 seconds */
         if ($Time > 1) {
             ReportCachePut($CacheKey, $V);
         }
     } else {
         $Cached = true;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     $Time = microtime(true) - $uTime;
     // convert usecs to secs
     $text = _("Elapsed time: %.2f seconds");
     printf("<small>{$text}</small>", $Time);
     $text = _("cached");
     $text1 = _("Update");
     if ($Cached) {
         echo " <i>{$text}</i>   <a href=\"{$_SERVER['REQUEST_URI']}&updcache=1\"> {$text1} </a>";
     }
     return;
 }
    /**
    * @brief Output(): 
    * Requires:\n
           filter: optional filter to apply\n
           item1:  uploadtree_pk of the column 1 tree\n
           item2:  uploadtree_pk of the column 2 tree\n
           freeze: column number (1 or 2) to freeze
    */
    function Output()
    {
        if ($this->State != PLUGIN_STATE_READY) {
            return 0;
        }
        $uTime = microtime(true);
        $V = "";
        /**/
        $UpdCache = GetParm("updcache", PARM_INTEGER);
        /* Remove "updcache" from the GET args and set $this->UpdCache
         * This way all the url's based on the input args won't be
         * polluted with updcache
         * Use Traceback_parm_keep to ensure that all parameters are in order
         */
        $CacheKey = "?mod=" . $this->Name . Traceback_parm_keep(array("item1", "item2", "filter", "col", "freeze", "itemf"));
        if ($UpdCache) {
            $UpdCache = $_GET['updcache'];
            $_SERVER['REQUEST_URI'] = preg_replace("/&updcache=[0-9]*/", "", $_SERVER['REQUEST_URI']);
            unset($_GET['updcache']);
            $V = ReportCachePurgeByKey($CacheKey);
        } else {
            $V = ReportCacheGet($CacheKey);
        }
        /**/
        if (empty($V)) {
            $filter = GetParm("filter", PARM_STRING);
            if (empty($filter)) {
                $filter = "none";
            }
            $FreezeCol = GetParm("freeze", PARM_INTEGER);
            // which column to freeze?  1 or 2 or null
            $ClickedCol = GetParm("col", PARM_INTEGER);
            // which column was clicked on?  1 or 2 or null
            $ItemFrozen = GetParm("itemf", PARM_INTEGER);
            // frozen item or null
            $in_uploadtree_pk1 = GetParm("item1", PARM_INTEGER);
            $in_uploadtree_pk2 = GetParm("item2", PARM_INTEGER);
            if (empty($in_uploadtree_pk1) || empty($in_uploadtree_pk2)) {
                Fatal("Bad input parameters.  Both item1 and item2 must be specified.", __FILE__, __LINE__);
            }
            /* If you click on a item in a frozen column, then you are a dope so ignore $ItemFrozen */
            if ($FreezeCol == $ClickedCol) {
                $ItemFrozen = 0;
                $FreezeCol = 0;
            }
            /* Check item1 upload permission */
            $Item1Row = GetSingleRec("uploadtree", "WHERE uploadtree_pk = {$in_uploadtree_pk1}");
            $UploadPerm = GetUploadPerm($Item1Row['upload_fk']);
            if ($UploadPerm < PERM_READ) {
                $text = _("Permission Denied");
                echo "<h2>{$text} item 1<h2>";
                return;
            }
            /* Check item2 upload permission */
            $Item2Row = GetSingleRec("uploadtree", "WHERE uploadtree_pk = {$in_uploadtree_pk2}");
            $UploadPerm = GetUploadPerm($Item2Row['upload_fk']);
            if ($UploadPerm < PERM_READ) {
                $text = _("Permission Denied");
                echo "<h2>{$text} item 2<h2>";
                return;
            }
            $uploadtree_pk1 = $in_uploadtree_pk1;
            $uploadtree_pk2 = $in_uploadtree_pk2;
            if ($FreezeCol == 1) {
                $uploadtree_pk1 = $ItemFrozen;
            } else {
                if ($FreezeCol == 2) {
                    $uploadtree_pk2 = $ItemFrozen;
                }
            }
            $newURL = Traceback_dir() . "?mod=" . $this->Name . "&item1={$uploadtree_pk1}&item2={$uploadtree_pk2}";
            if (!empty($filter)) {
                $newURL .= "&filter={$filter}";
            }
            // rewrite page with new uploadtree_pks */
            if ($uploadtree_pk1 != $in_uploadtree_pk1 || $uploadtree_pk2 != $in_uploadtree_pk2) {
                print <<<JSOUT
<script type="text/javascript">
  window.location.assign('{$newURL}');
</script>
JSOUT;
            }
            $TreeInfo1 = $this->GetTreeInfo($uploadtree_pk1);
            $TreeInfo2 = $this->GetTreeInfo($uploadtree_pk2);
            $ErrText = _("No license data for tree %d.  Use Jobs > Agents to schedule a license scan.");
            $ErrMsg = '';
            if ($TreeInfo1['agent_pk'] == 0) {
                $ErrMsg = sprintf($ErrText, 1);
            } else {
                if ($TreeInfo2['agent_pk'] == 0) {
                    $ErrMsg = sprintf($ErrText, 2);
                } else {
                    $BucketDefArray = initBucketDefArray($TreeInfo1['bucketpool_pk']);
                    /* Get list of children */
                    $Children1 = GetNonArtifactChildren($uploadtree_pk1);
                    $Children2 = GetNonArtifactChildren($uploadtree_pk2);
                    /* Add fuzzyname to children */
                    FuzzyName($Children1);
                    // add fuzzyname to children
                    FuzzyName($Children2);
                    // add fuzzyname to children
                    /* add element licstr to children */
                    $this->AddBucketStr($TreeInfo1, $Children1, $BucketDefArray);
                    $this->AddBucketStr($TreeInfo2, $Children2, $BucketDefArray);
                    /* Master array of children, aligned.   */
                    $Master = MakeMaster($Children1, $Children2);
                    /* add linkurl to children */
                    FileList($Master, $TreeInfo1['agent_pk'], $TreeInfo2['agent_pk'], $filter, $this, $uploadtree_pk1, $uploadtree_pk2);
                    /* Apply filter */
                    $this->FilterChildren($filter, $Master, $BucketDefArray);
                }
            }
            switch ($this->OutputType) {
                case "XML":
                    break;
                case "HTML":
                    if ($ErrMsg) {
                        $V .= $ErrMsg;
                    } else {
                        $V .= $this->HTMLout($Master, $uploadtree_pk1, $uploadtree_pk2, $in_uploadtree_pk1, $in_uploadtree_pk2, $filter, $TreeInfo1, $TreeInfo2, $BucketDefArray);
                    }
                    break;
                case "Text":
                    break;
                default:
            }
            $Cached = false;
        } else {
            $Cached = true;
        }
        if (!$this->OutputToStdout) {
            return $V;
        }
        print "{$V}";
        $Time = microtime(true) - $uTime;
        // convert usecs to secs
        $text = _("Elapsed time: %.2f seconds");
        printf("<small>{$text}</small>", $Time);
        /**/
        if ($Cached) {
            $text = _("cached");
            $text1 = _("Update");
            echo " <i>{$text}</i>   <a href=\"{$_SERVER['REQUEST_URI']}&updcache=1\"> {$text1} </a>";
        } else {
            //  Cache Report if this took longer than 1/2 second
            if ($Time > 0.5) {
                ReportCachePut($CacheKey, $V);
            }
        }
        /**/
        return;
    }
 /**
  * \brief This function returns the scheduler status.
  */
 function Output()
 {
     $uTime = microtime(true);
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $V = "";
     $Upload = GetParm("upload", PARM_INTEGER);
     $UploadPerm = GetUploadPerm($Upload);
     if ($UploadPerm < PERM_READ) {
         $text = _("Permission Denied");
         echo "<h2>{$text}<h2>";
         return;
     }
     $Item = GetParm("item", PARM_INTEGER);
     $tag_pk = GetParm("tag", PARM_INTEGER);
     $updcache = GetParm("updcache", PARM_INTEGER);
     $this->uploadtree_tablename = GetUploadtreeTableName($Upload);
     /* Remove "updcache" from the GET args.
      * This way all the url's based on the input args won't be
      * polluted with updcache
      * Use Traceback_parm_keep to ensure that all parameters are in order */
     $CacheKey = "?mod=" . $this->Name . Traceback_parm_keep(array("upload", "item", "tag", "agent", "orderBy", "orderl", "orderc"));
     if ($updcache) {
         $_SERVER['REQUEST_URI'] = preg_replace("/&updcache=[0-9]*/", "", $_SERVER['REQUEST_URI']);
         unset($_GET['updcache']);
         $V = ReportCachePurgeByKey($CacheKey);
     } else {
         $V = ReportCacheGet($CacheKey);
     }
     if (empty($V)) {
         switch ($this->OutputType) {
             case "XML":
                 break;
             case "HTML":
                 $V .= "<font class='text'>\n";
                 /************************/
                 /* Show the folder path */
                 /************************/
                 $V .= Dir2Browse($this->Name, $Item, NULL, 1, "Browse", -1, '', '', $this->uploadtree_tablename) . "<P />\n";
                 if (!empty($Upload)) {
                     $Uri = preg_replace("/&item=([0-9]*)/", "", Traceback());
                     $V .= js_url();
                     $V .= $this->ShowUploadHist($Item, $Uri, $tag_pk);
                 }
                 $V .= "</font>\n";
                 $text = _("Loading...");
                 /*$V .= "<div id='ajax_waiting'><img src='images/ajax-loader.gif'>$text</div>"; */
                 break;
             case "Text":
                 break;
             default:
         }
         $Cached = false;
     } else {
         $Cached = true;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     $Time = microtime(true) - $uTime;
     // convert usecs to secs
     $text = _("Elapsed time: %.2f seconds");
     printf("<small>{$text}</small>", $Time);
     if ($Cached) {
         $text = _("cached");
         $text1 = _("Update");
         echo " <i>{$text}</i>   <a href=\"{$_SERVER['REQUEST_URI']}&updcache=1\"> {$text1} </a>";
     } else {
         /*  Cache Report if this took longer than 1/2 second*/
         if ($Time > 0.5) {
             ReportCachePut($CacheKey, $V);
         }
     }
     return;
 }
 /**
  * \brief test for ReportCacheGet 
  */
 function testReportCacheGet()
 {
     print "test function ReportCacheGet()\n";
     global $PG_CONN;
     global $upload_pk;
     global $uploadtree_pk;
     global $UserCacheStat;
     $this->preparation4ReportCachePut();
     /** put an Cache record */
     $CacheKey = "?mod=nomoslicense&upload={$upload_pk}&item={$uploadtree_pk}&show=detail";
     $CacheValue = "no data";
     ReportCachePut($CacheKey, $CacheValue);
     /** get the cache value thru CacheKey */
     $UserCacheStat = 2;
     /**<  Cache is off for this user */
     $value = ReportCacheGet($CacheKey);
     $this->assertEquals($CacheValue, $value);
     $this->resetEnv4ReportCachePut();
     print "unit test for common-cache.php end\n";
 }
示例#6
0
 /**
 * @brief Output(): 
 * Requires:\n
        filter: optional filter to apply\n
        item1:  uploadtree_pk of the column 1 tree\n
        item2:  uploadtree_pk of the column 2 tree\n
        freeze: column number (1 or 2) to freeze
 */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $uTime = microtime(true);
     $V = "";
     $UpdCache = GetParm("updcache", PARM_INTEGER);
     /* Remove "updcache" from the GET args and set $this->UpdCache
      * This way all the url's based on the input args won't be
      * polluted with updcache
      * Use Traceback_parm_keep to ensure that all parameters are in order
      */
     $CacheKey = "?mod=" . $this->Name . Traceback_parm_keep(array("item1", "item2", "filter", "col", "freeze", "itemf"));
     if ($UpdCache) {
         $UpdCache = $_GET['updcache'];
         $_SERVER['REQUEST_URI'] = preg_replace("/&updcache=[0-9]*/", "", $_SERVER['REQUEST_URI']);
         unset($_GET['updcache']);
         $V = ReportCachePurgeByKey($CacheKey);
     } else {
         $V = ReportCacheGet($CacheKey);
     }
     $Cached = !empty($V);
     if (!$Cached) {
         $V = $this->htmlContent();
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     $Time = microtime(true) - $uTime;
     // convert usecs to secs
     $text = _("Elapsed time: %.2f seconds");
     printf("<small>{$text}</small>", $Time);
     if ($Cached) {
         $text = _("cached");
         $text1 = _("Update");
         echo " <i>{$text}</i>   <a href=\"{$_SERVER['REQUEST_URI']}&updcache=1\"> {$text1} </a>";
     } else {
         if ($Time > 0.5) {
             ReportCachePut($CacheKey, $V);
         }
     }
     return;
 }