Пример #1
0
 /**
  * \brief This function is called before the plugin
  * is used and after all plugins have been initialized.
  * 
  * \return on success, false on failure.
  * \note Do not assume that the plugin exists!  Actually check it!
  * Purpose: Only allow people who are logged in to edit their own properties.
  */
 function PostInitialize()
 {
     global $Plugins;
     if ($this->State != PLUGIN_STATE_VALID) {
         return 0;
     }
     // don't run
     if ($_SESSION['User'] == "Default User") {
         /* Only valid if the user is logged in. */
         $this->State = PLUGIN_STATE_INVALID;
         return 0;
     }
     // Make sure dependencies are met
     foreach ($this->Dependency as $key => $val) {
         $id = plugin_find_id($val);
         if ($id < 0) {
             $this->Destroy();
             return 0;
         }
     }
     // It worked, so mark this plugin as ready.
     $this->State = PLUGIN_STATE_READY;
     // Add this plugin to the menu
     if ($this->MenuList !== "") {
         menu_insert("Main::" . $this->MenuList, $this->MenuOrder, $this->Name, $this->MenuTarget);
     }
     return $this->State == PLUGIN_STATE_READY;
 }
Пример #2
0
 /**
  * \brief Register copyright agent in "Agents" menu
  */
 function RegisterMenus()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     menu_insert("Agents::" . $this->Title, 0, $this->Name);
 }
Пример #3
0
 protected function RegisterMenus()
 {
     parent::RegisterMenus();
     if (!$this->isRequiresLogin() || $this->isLoggedIn()) {
         menu_insert("Main::Organize::Uploads::Move or Copy", 0, $this->name, $this->name);
     }
 }
Пример #4
0
 function PostInitialize()
 {
     global $Plugins;
     if ($this->State != PLUGIN_STATE_VALID) {
         return 0;
     }
     // don't run
     // Make sure dependencies are met
     foreach ($this->Dependency as $key => $val) {
         $id = plugin_find_id($val);
         if ($id < 0) {
             Destroy();
             return 0;
         }
     }
     // Add default menus (with no actions linked to plugins)
     menu_insert("Main::Upload", 70);
     menu_insert("Main::Jobs", 60);
     menu_insert("Main::Organize", 50);
     menu_insert("Main::Help", -1);
     menu_insert("Main::Help::Documentation", 0, NULL, NULL, NULL, "<a href='http://www.fossology.org/projects/fossology/wiki/User_Documentation'>Documentation</a>");
     // It worked, so mark this plugin as ready.
     $this->State = PLUGIN_STATE_READY;
     return $this->State == PLUGIN_STATE_READY;
 }
Пример #5
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     $tooltipText = _("View file information");
     menu_insert("Browse-Pfile::Info", 5, $this->Name, $tooltipText);
     // For the Browse menu, permit switching between detail and summary.
     $Parm = Traceback_parm_keep(array("upload", "item", "format"));
     $URI = $this->Name . $Parm;
     $menuPosition = 60;
     $menuText = "Info";
     if (GetParm("mod", PARM_STRING) == $this->Name) {
         menu_insert("View::[BREAK]", 61);
         menu_insert("View::[BREAK]", 50);
         menu_insert("View::{$menuText}", $menuPosition);
         menu_insert("View-Meta::[BREAK]", 61);
         menu_insert("View-Meta::[BREAK]", 50);
         menu_insert("View-Meta::{$menuText}", $menuPosition);
         menu_insert("Browse::Info", -3);
     } else {
         $tooltipText = _("View information about this file");
         menu_insert("View::[BREAK]", 61);
         menu_insert("View::[BREAK]", 50);
         menu_insert("View::{$menuText}", $menuPosition, $URI, $tooltipText);
         menu_insert("View-Meta::[BREAK]", 61);
         menu_insert("View-Meta::[BREAK]", 50);
         menu_insert("View-Meta::{$menuText}", $menuPosition, $URI, $tooltipText);
         menu_insert("Browse::Info", -3, $URI, $tooltipText);
     }
 }
Пример #6
0
 /**
  * \brief Register additional menus.
  */
 function RegisterMenus()
 {
     global $SysConf;
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     // don't run
     /* Get the users.default_bucketpool_fk */
     $AuthRec = GetArrayval('auth', $SysConf);
     if (empty($AuthRec)) {
         return 0;
     }
     $user_pk = $SysConf['auth']['UserId'];
     /* Unless the user is authenticated, we can't do anything. */
     if (empty($user_pk)) {
         return 0;
     }
     /* Get users default bucketpool so we know which bucketpool to use. */
     $usersRec = GetSingleRec("users", "where user_pk='{$user_pk}'");
     $default_bucketpool_fk = $usersRec['default_bucketpool_fk'];
     if (empty($default_bucketpool_fk)) {
         return 0;
     }
     /* fake menu item used to identify plugin agents */
     menu_insert("Agents::" . $this->Title, 0, $this->Name);
 }
Пример #7
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
     $MenuDisplayString = _("License List");
     $MenuDisplayStringDL = _("License List Download");
     $Item = GetParm("item", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (empty($Item) || empty($Upload)) {
         return;
     }
     if (GetParm("mod", PARM_STRING) == $this->Name) {
         menu_insert("Browse::{$MenuDisplayString}", 1);
         menu_insert("Browse::{$MenuDisplayStringDL}", 1, $URI . "&output=dltext");
     } else {
         menu_insert("Browse::{$MenuDisplayString}", 1, $URI, $MenuDisplayString);
         menu_insert("Browse::{$MenuDisplayStringDL}", 1, $URI . "&output=dltext", $MenuDisplayStringDL);
         /* bobg - This is to use a select list in the micro menu to replace the above List
             and Download, but put this select list in a form
             $LicChoices = array("Lic Download" => "Download", "Lic display" => "Display");
             $LicChoice = Array2SingleSelect($LicChoices, $SLName="LicDL");
             menu_insert("Browse::Nomos License List Download2", 1, $URI . "&output=dltext", NULL,NULL, $LicChoice);
            */
     }
 }
Пример #8
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     $topMenuList = "Main::" . "Help::Getting Started";
     $menuOrder = 0;
     menu_insert($topMenuList . '::Overview', $menuOrder - 10, $this->getName() . "&show=welcome");
     menu_insert($topMenuList . '::License Browser', $menuOrder, $this->getName() . "&show=licensebrowser");
 }
Пример #9
0
 function preInstall()
 {
     $bucketPool = $this->getDefaultBucketPool();
     if (!empty($bucketPool)) {
         menu_insert("Agents::" . $this->Title, 0, $this->Name);
     }
 }
 /**
  * \brief This is where we check for
  * changes to the full-debug setting.
  */
 function PostInitialize()
 {
     if ($this->State != PLUGIN_STATE_VALID) {
         return 0;
     }
     // don't re-run
     // Make sure dependencies are met
     foreach ($this->Dependency as $key => $val) {
         $id = plugin_find_id($val);
         if ($id < 0) {
             $this->Destroy();
             return 0;
         }
     }
     $FullMenuDebug = GetParm("fullmenu", PARM_INTEGER);
     if ($FullMenuDebug == 2) {
         $_SESSION['fullmenudebug'] = 1;
     }
     if ($FullMenuDebug == 1) {
         $_SESSION['fullmenudebug'] = 0;
     }
     // It worked, so mark this plugin as ready.
     $this->State = PLUGIN_STATE_READY;
     // Add this plugin to the menu
     if ($this->MenuList !== "") {
         menu_insert("Main::" . $this->MenuList, $this->MenuOrder, $this->Name, $this->MenuTarget);
     }
     return 1;
 }
Пример #11
0
 /**
  * \brief Register additional menus.
  **/
 function RegisterMenus()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     // don't run
     /* fake menu item used to identify plugin agents */
     menu_insert("Agents::" . $this->Title, 0, $this->Name);
 }
Пример #12
0
 function preInstall()
 {
     $dbManager = $GLOBALS['container']->get('db.manager');
     $latestPkgAgent = $dbManager->getSingleRow("SELECT agent_enabled FROM agent WHERE agent_name=\$1 ORDER BY agent_ts LIMIT 1", array('pkgagent'));
     if (isset($latestPkgAgent) && !$dbManager->booleanFromDb($latestPkgAgent['agent_enabled'])) {
         return 0;
     }
     menu_insert("Agents::" . $this->Title, 0, $this->Name);
 }
Пример #13
0
 function preInstall()
 {
     $text = _("Generate SPDX report");
     menu_insert("Browse-Pfile::Export&nbsp;SPDX&nbsp;RDF", 0, self::NAME, $text);
     menu_insert("UploadMulti::Generate&nbsp;SPDX", 0, self::NAME, $text);
     $text = _("Generate SPDX report in tag:value format");
     menu_insert("Browse-Pfile::Export&nbsp;SPDX&nbsp;tag:value", 0, self::NAME . '&outputFormat=spdx2tv', $text);
     $text = _("Generate Debian Copyright file");
     menu_insert("Browse-Pfile::Export&nbsp;DEP5", 0, self::NAME . '&outputFormat=dep5', $text);
 }
Пример #14
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $URL = $this->Name . "&add=y";
     $text = _("Add new license");
     menu_insert("Main::" . $this->MenuList . "::Add License", 0, $URL, $text);
     $URL = $this->Name;
     $text = _("Select license family");
     menu_insert("Main::" . $this->MenuList . "::Select License", 0, $URL, $text);
 }
Пример #15
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     // micro-menu
     $bucketagent_pk = GetParm("bapk", PARM_INTEGER);
     $uploadtree_pk = GetParm("item", PARM_INTEGER);
     $bucket_pk = GetParm("bpk", PARM_INTEGER);
     $bucketpool_pk = GetParm("bp", PARM_INTEGER);
     $nomosagent_pk = GetParm("napk", PARM_INTEGER);
     $URL = $this->Name . "&bapk={$bucketagent_pk}&item={$uploadtree_pk}&bpk={$bucket_pk}&bp={$bucketpool_pk}&napk={$nomosagent_pk}&page=-1";
     $text = _("Show All Files");
     menu_insert($this->Name . "::Show All", 0, $URL, $text);
 }
Пример #16
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("upload", "item"));
     $MenuName = "Demomod View";
     $Item = GetParm("item", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (!empty($Item)) {
         $text = _("Demomod data");
         menu_insert("Browse::{$MenuName}", 100, $URI, $text);
         menu_insert("View::{$MenuName}", 100, $URI, $text);
     }
 }
 /**
  * \brief This is where we check for
  * changes to the full-debug setting.
  */
 function PostInitialize()
 {
     if ($this->State != PLUGIN_STATE_VALID) {
         return 0;
     }
     // don't re-run
     // It worked, so mark this plugin as ready.
     $this->State = PLUGIN_STATE_READY;
     // Add this plugin to the menu
     if ($this->MenuList !== "") {
         menu_insert("Main::" . $this->MenuList, $this->MenuOrder, $this->Name, $this->MenuTarget);
     }
     return 1;
 }
Пример #18
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     menu_insert("Main::" . $this->MenuList, $this->MenuOrder, $this->Name, $this->MenuTarget);
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("page", "item"));
     $Item = GetParm("item", PARM_INTEGER);
     if (!empty($Item)) {
         if (GetParm("mod", PARM_STRING) == $this->Name) {
             menu_insert("Browse::Search", 1);
         } else {
             menu_insert("Browse::Search", 1, $URI, $this->MenuList);
         }
     }
 }
Пример #19
0
 function RegisterMenus()
 {
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
     $Item = GetParm("item", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (!empty($Item) && !empty($Upload)) {
         if (GetParm("mod", PARM_STRING) == $this->Name) {
             menu_insert("Browse::ECC", 1);
             menu_insert("Browse::[BREAK]", 100);
         } else {
             $text = _("View ECC histogram");
             menu_insert("Browse::ECC", 10, $URI, $text);
         }
     }
 }
Пример #20
0
 /**
  * \brief Register additional menus.
  */
 function RegisterMenus()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     // don't run
     global $PG_CONN;
     $sql = "SELECT agent_enabled FROM agent WHERE agent_name ='pkgagent' order by agent_ts LIMIT 1;";
     $result = pg_query($PG_CONN, $sql);
     $row = pg_fetch_assoc($result);
     pg_free_result($result);
     if (isset($row) && $row['agent_enabled'] == 'f') {
         return 0;
     }
     menu_insert("Agents::" . $this->Title, 0, $this->Name);
 }
Пример #21
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     menu_insert("Main::" . $this->MenuList, $this->MenuOrder, $this->Name, $this->Name);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (empty($Upload)) {
         return;
     }
     // For the Browse menu, permit switching between detail and simple.
     $URI = $this->Name . Traceback_parm_keep(array("upload", "item"));
     if (GetParm("mod", PARM_STRING) == $this->Name) {
         menu_insert("Browse::Browse", 1);
     } else {
         menu_insert("Browse::Browse", 1, $URI);
     }
     return $this->State == PLUGIN_STATE_READY;
 }
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     // micro-menu
     $uploadtree_pk = GetParm("item", PARM_INTEGER);
     $rf_shortname = GetParm("lic", PARM_STRING);
     $Excl = GetParm("excl", PARM_RAW);
     $URL = $this->Name . "&item={$uploadtree_pk}&lic={$rf_shortname}&page=-1";
     if (!empty($Excl)) {
         $URL .= "&excl={$Excl}";
     }
     $text = _("Show All Files");
     menu_insert($this->Name . "::Show All", 0, $URL, $text);
 }
Пример #23
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     $tooltipText = _("View file contents");
     menu_insert("Browse-Pfile::View", 10, $this->Name, $tooltipText);
     // For the Browse menu, permit switching between detail and summary.
     $itemId = GetParm("item", PARM_INTEGER);
     $textFormat = $this->microMenu->getFormatParameter($itemId);
     $pageNumber = GetParm("page", PARM_INTEGER);
     $this->microMenu->addFormatMenuEntries($textFormat, $pageNumber);
     $URI = Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
     $menuPosition = 59;
     $menuText = "View";
     $tooltipText = _("View file contents");
     $this->microMenu->insert(MicroMenu::TARGET_DEFAULT, $menuText, $menuPosition, $this->Name, $this->Name . $URI, $tooltipText);
     if (GetParm("mod", PARM_STRING) != $this->Name) {
         menu_insert("Browse::{$menuText}", -2, $this->Name . $URI, $tooltipText);
         menu_insert("Browse::[BREAK]", -1);
     }
 }
Пример #24
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
     $Item = GetParm("item", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (!empty($Item) && !empty($Upload)) {
         if (GetParm("mod", PARM_STRING) == $this->Name) {
             menu_insert("Browse::bsam License", -5);
             menu_insert("Browse::[BREAK]", -3);
             $text = _("Clear");
             menu_insert("Browse::Clear", -4, NULL, NULL, NULL, "<a href='javascript:LicColor(\"\",\"\",\"\",\"\");'>{$text}</a>");
         } else {
             $text = _("View bsam license histogram");
             menu_insert("Browse::[BREAK]", -3);
             menu_insert("Browse::bsam License", -5, $URI, $text);
         }
     }
 }
Пример #25
0
 function RegisterMenus()
 {
     menu_insert("Main::Jobs::My Recent Jobs", $this->MenuOrder - 1, $this->Name, $this->MenuTarget);
     if (@$_SESSION['UserLevel'] != PLUGIN_DB_ADMIN) {
         return;
     }
     if (GetParm("mod", PARM_STRING) == $this->Name) {
         /* Set micro menu to select either all users or this user */
         $allusers = GetParm("allusers", PARM_INTEGER);
         if ($allusers == 0) {
             $text = _("Show uploads from all users");
             $URI = $this->Name . Traceback_parm_keep(array("page")) . "&allusers=1";
         } else {
             $text = _("Show only your own uploads");
             $URI = $this->Name . Traceback_parm_keep(array("page")) . "&allusers=0";
         }
         menu_insert("showjobs::{$text}", 1, $URI, $text);
     }
 }
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("upload", "item"));
     $Item = GetParm("item", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (!empty($Item) && !empty($Upload)) {
         $nomosAgentpk = LatestAgentpk($Upload, "nomos_ars");
         $nomosURI = "view-license&napk={$nomosAgentpk}" . Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
         if (GetParm("mod", PARM_STRING) == $this->Name) {
             menu_insert("Browse::License Browser", 100);
         } else {
             $text = _("license histogram");
             $MenuName = "License Browser";
             menu_insert("Browse::{$MenuName}", 100, $URI, $text);
             menu_insert("View::{$MenuName}", 100, $nomosURI, $text);
         }
     }
 }
Пример #27
0
 /**
  * \brief This is where the magic for
  * mod=init happens.
  * This plugin only runs when the special file
  * "..../www/init.ui" exists!
  */
 function PostInitialize()
 {
     if ($this->State != PLUGIN_STATE_VALID) {
         return 1;
     }
     // don't re-run
     /** Disable everything but me, DB, menu **/
     /* Enable or disable plugins based on login status */
     global $Plugins;
     $Filename = getcwd() . "/init.ui";
     if (!file_exists($Filename)) {
         $this->State = PLUGIN_STATE_INVALID;
         return;
     }
     $Max = count($Plugins);
     for ($i = 0; $i < $Max; $i++) {
         $P =& $Plugins[$i];
         if ($P->State == PLUGIN_STATE_INVALID) {
             continue;
         }
         /* Don't turn off plugins that are already up and running. */
         if ($P->State == PLUGIN_STATE_READY) {
             continue;
         }
         if ($P->DBaccess == PLUGIN_DB_ADMIN) {
             continue;
         }
         $Key = array_search($P->Name, $this->Dependency);
         if ($Key === FALSE && strcmp($P->Name, $this->Name)) {
             // print "Disable " . $P->Name . " as $Key <br>\n";
             $P->Destroy();
             $P->State = PLUGIN_STATE_INVALID;
         } else {
             // print "Keeping " . $P->Name . " as $Key <br>\n";
         }
     }
     $this->State = PLUGIN_STATE_READY;
     if ($_SESSION[Auth::USER_LEVEL] >= PLUGIN_DB_ADMIN && $this->MenuList !== "") {
         menu_insert("Main::" . $this->MenuList, $this->MenuOrder, $this->Name, $this->MenuTarget);
     }
     return $this->State == PLUGIN_STATE_READY;
 }
Пример #28
0
 function RegisterMenus()
 {
     menu_insert("Main::Jobs::My Recent Jobs", $this->MenuOrder - 1, $this->Name, $this->MenuTarget);
     if ($_SESSION[Auth::USER_LEVEL] == PLUGIN_DB_ADMIN) {
         $URIpart = $this->Name . Traceback_parm_keep(array("page")) . "&allusers=";
         menu_insert("Main::Jobs::All Recent Jobs", $this->MenuOrder - 2, $URIpart . '1', $this->MenuTarget);
         if (GetParm("mod", PARM_STRING) == $this->Name) {
             /* Set micro menu to select either all users or this user */
             $allusers = GetParm("allusers", PARM_INTEGER);
             if ($allusers == 0) {
                 $text = _("Show uploads from all users");
                 $URI = $URIpart . "1";
             } else {
                 $text = _("Show only your own uploads");
                 $URI = $URIpart . "0";
             }
             menu_insert("showjobs::{$text}", 1, $URI, $text);
         }
     }
 }
Пример #29
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     if (GetParm("mod", PARM_STRING) == $this->Name) {
         $detail = GetParm("detail", PARM_INTEGER);
         if ($detail) {
             $text = _("ACME High Level Review");
             $URI = $this->Name . Traceback_parm_keep(array("page", "upload", "folic")) . "&detail=0";
         } else {
             $text = _("ACME Low Level Review");
             $URI = $this->Name . Traceback_parm_keep(array("page", "upload", "folic")) . "&detail=1";
         }
         // micro menu when in acme_review
         menu_insert("acme::{$text}", 1, $URI, $text);
     } else {
         // micro menu item when not in acme_review
         $text2 = _("ACME Review");
         $URI = $this->Name . Traceback_parm_keep(array("page", "upload")) . "&detail=0";
         menu_insert("Browse::{$text2}", 1, $URI, $text2);
     }
 }
Пример #30
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     // micro-menu
     $agent_pk = GetParm("agent", PARM_INTEGER);
     $uploadtree_pk = GetParm("item", PARM_INTEGER);
     $hash = GetParm("hash", PARM_RAW);
     $type = GetParm("type", PARM_RAW);
     $Page = GetParm("page", PARM_INTEGER);
     $Excl = GetParm("excl", PARM_RAW);
     $filter = GetParm("filter", PARM_RAW);
     $URL = $this->Name . "&agent={$agent_pk}&item={$uploadtree_pk}&hash={$hash}&type={$type}&page=-1";
     if (!empty($Excl)) {
         $URL .= "&excl={$Excl}";
     }
     $text = _("Show All Files");
     menu_insert($this->Name . "::Show All", 0, $URL, $text);
 }