Source for file PRO_GROUP_NODE.phpclass
Documentation is available at PRO_GROUP_NODE.phpclass
* Class file PRO_GROUP_NODE.phpclass
* @project Open CSP-Management
* @author Peter Krebs (pk) <p.krebs@wpus.at>
* @copyright (c) 2002-2004 by Peter Krebs and Landesverlag Unternehmensservice
* @copyright (c) 2005 by WURM & Partner Unternehmensservice GmbH
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
require_once $GLOBALS['OCSP']['PHPINCPATH'].
'db/DBMS_TREE_NODE.phpclass';
* @project Open CSP-Management
* @author Peter Krebs (pk) <p.krebs@wpus.at>
* @copyright (c) 2002-2004 by Peter Krebs and Landesverlag Unternehmensservice
* @copyright (c) 2005 by WURM & Partner Unternehmensservice GmbH
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @var string $myGlobalTreeKey index in $GLOABLS['DBMS_TREE'][]
* @staticvar string $myTable
* @staticvar string $myIdFld id column = root
* @staticvar string $myParentFld name of the parent column
* @staticvar string $mySortFld name of the sort field
* @var string $myChildClass
* @var array $myGrpTypeArr row of T_PRO_GRPTYPE
* @staticvar $myClassSrcFile
* @var string $prodFilter
* @var double $prodPopulateTS
// ######################################
* inserts a new row to the table
* @param string $gDBIDX Index of $GLOBALS to the db object
* @param bool $debug show debug info
* @return int returns the autoIncFld ID if exists or 1 on success
function dbInsert($gDBIDX=
"USRDB",$debug=
FALSE) {
if ($debug) echo
"<hr><p><b>PRO_GROUP_NODE::dbInsert($gDBIDX,$debug)</b> (".
get_class($this).
")</p>";
$this->{$this->mySortFld} =
$GLOBALS[$gDBIDX]->quickQuery($query,0,0);
$this->PGP_CREATION=
"CURRENT_TIMESTAMP";
return parent::dbInsert($gDBIDX,$debug);
* replaces a row in the table
* if the object has not been populated (!$this->populateTS)
* @param string $gDBIDX Index of $GLOBALS to the db object
* @param boolean $debug show debug info
function dbReplace($gDBIDX=
"USRDB",$debug=
FALSE) {
if ($debug) echoDebug(__FILE__
,"<p><b>PRO_GROUP_NODE::dbReplace(...)</b> (".
get_class($this).
")</p>",0);
$this->PGP_LASTCHANGE=
"CURRENT_TIMESTAMP";
return parent::dbReplace($gDBIDX,$debug);
* adds a node to childArray($key)
* @param DBMS_TREE_NODE $aNode
* returns the Title or the name if title is null
return intval($this->PROJ_ID);
* returns the language id
// ###########################################################################
// ###########################################################################
* returns the product group type ID
* sets the product group type ID
* selects the type row form T_PRO_GRPTYPE
'PGT_NAME' =>
"[default]",
'PGT_PROLST_FRM_ID' =>
0,
$query=
"SELECT * FROM T_PRO_GRPTYPE WHERE PGT_ID=".
intval($this->getDBField('PGT_ID'));
if ($debug) echo
"<blockquote><p style=\"font-size:75%\">Query: $query</p></blockquote>";
if ($this->myGrpTypeArr=
$GLOBALS[$this->get_gDBIDX()]->quickQuery($query)) {
* returns a form for table T_PRO_GROUP
* if $frmName isset this form is returned
* if $frmName is empty the form assigned to the type is returned
function &dbGetForm($mode,$frmName=
"",$debug=
FALSE) {
if ($debug) echo
"<p>Loading Form ID : ".
$this->myGrpTypeArr['FRM_ID'].
"</p><blockquote style=\"font-size: 75%\">";
$frmObj->myDBMS_TABLEOBJ_class =
get_class($this);
if ($debug) echo
"</blockquote>";
if ($debug) echo
"</blockquote>";
if ($debug) echo
"<p>Loading Default Form or named Form!!!</p>";
return parent::dbGetForm($mode,$frmName,FALSE);
* checks if the node is on
* @param boolean $checkDate
* @param boolean $checkGroup
* @param boolean $checkShow
function isToShow($checkDate=
TRUE,$checkGroup=
TRUE,$debug=
FALSE,$checkShow=
TRUE,$checkProducts=
TRUE,$checkParts=
FALSE){
if (!$this->PGP_SHOW &&
($checkShow)) {
if (!is_object($GLOBALS['USER'])) return FALSE;
if ((intval($this->PGP_GROUP)) &&
(!($GLOBALS['USER']->isGroupMember($this->PGP_GROUP)))) {
if (!empty($this->PGP_SHOWQUERY)) {
require_once $GLOBALS['PROJECT']['PHPINCPATH'].
"common/pcf_templates.phpinc";
// $debug=TRUE; echo "<tr><td>"; foreach($_SESSION as $key => $val) echo "<li>$key = $val</li>"; echo "</td></tr>";
if ($debug) echo
"<tr><td><pre>checkShowNode(".
$node['PGP_ID'].
") SHOWQUERY: \n$query</pre></td></tr>";
if (!(intval($GLOBALS[$this->gDBIDX]->quickQuery($query,0)))) return FALSE;
if ($this->hasProductsToShow($checkShow,$checkDate,$checkGroup,$checkParts,$debug)) {
* checks if the node has children which are on
* @param bool $filtered use filter
* @param bool $checkGroup
function hasChildrenToShow($filtered=
FALSE,$checkDate=
TRUE,$checkGroup=
TRUE,$debug=
FALSE){
if ($debug) echo
"<p><b>PRO_GROUP_NODE::hasChildrenToShow($checkDate,$checkGroup,...)</b> (".
get_class($this).
")</p>";
foreach($childArr as $child) {
if ($child->isToShow($checkDate,$checkGroup,$debug)) return TRUE;
* checks if the menu is to show from date
* - 0: showtill is outdate
* - -2: showfrom is not reached
require_once $GLOBALS['PROJECT']['PHPINCPATH'].
"common/pcf_Date.phpclass";
$now=
new pcf_Date(time());
$aDate->setDateStr($this->PGP_SHOWFROM);
if ($aDate->getLinuxTime() >
$now->getLinuxTime()) return -
2;
$aDate->setDateStr($this->PGP_SHOWTILL);
if ($aDate->getLinuxTime() <
$now->getLinuxTime()) return 0;
// #####################################################################################
// #####################################################################################
* returns if produkts are allowed in the group
* @since pk-07-02-14 (Tableversion 15)
return TRUE; // the default value
* returns the default product type for products in this group
* if the current value is 0 ([default]) the tree is searched upwords
return $o_node->getDefaultProdTypeId($debug);
* sets a where clause for products
* if this is set it PRO_GROUP_NODE::getProductWhere returnes
* it without modification
* returns a query to select all products
* @param boolean $showAll
* @param string $whereAdd
if ($debug) echo
"<p><b>PRO_GROUP_NODE::getProductWhere($showAll,$whereAdd ..)</b> (".
get_class($this).
")</p>";
if ($debug) echo
"<p>RETURNING FIXED WHERE</p>";
$query =
" WHERE PGP_ID =".
$this->getId();
$query.=
" AND PRO_SHOW > 0";
$query.=
" AND PRO_SHOWFROM <= NOW()";
$query.=
" AND PRO_SHOWTILL >= NOW()";
$query.=
" ORDER BY PRO_SORTORDER ";
* returns an array of PRODUCT objects
* @param boolean $showAll
* @param string $whereAdd
* @param boolean $forceReload
* @version pk-06-02-08 cache added
function getProducts($showAll=
FALSE,$whereAdd=
"",$debug=
FALSE,$forceReload=
FALSE) {
if ($debug) echoDebug(__FILE__
,"<p><b>PRO_GROUP_NODE::getProducts(...)</b> (".
get_class($this).
")</p>",0);
$a_cache=
$GLOBALS['OCSP']['CACHE']['PGP_PRODUCTS'][$this->getId()];
// we have a valid cache return it
require_once $GLOBALS['PRODUCTS']['PHPINCPATH'].
"PRO_PRODUCT.phpclass";
$query=
"SELECT * FROM T_PRO_PRODUCT ".
$this->getProductWhere($showAll,$whereAdd,$debug);
if ($debug) echoDebug(__FILE__
,"<p>Query: $query</p>",1);
if ($cursor=
$GLOBALS[$this->get_gDBIDX()]->query($query)) {
while($row=
$cursor->fetchArrayFld()) {
$a_cache[$idx]->setDBRow($row,TRUE,$debug);
$a_cache[$idx]->setMyProGrp($this,$debug);
$GLOBALS['OCSP']['CACHE']['PGP_PRODUCTS'][$this->getId()]=
$a_cache;
* returns if the group has products to show
* @param boolean $checkShow
* @param boolean $checkDate
* @param boolean $checkGroup
* @param boolean $checkParts
* @param boolean $checkChildren
* @param boolean $forceReload
* @todo check group children
function hasProductsToShow($checkShow=
TRUE,$checkDate=
TRUE,$checkGroup=
TRUE,$checkParts=
FALSE,$debug=
FALSE,$checkChildren=
TRUE,$forceReload=
FALSE) {
if ($debug) echoDebug(__FILE__
,"<p><b>PRO_GROUP_NODE::hasProductsToShow(...)</b> (".
get_class($this).
")</p>",0);
$b_showAll=
(($checkShow &&
$checkDate) ?
FALSE :
TRUE);
$a_prods=
$this->getProducts($b_showAll,"",$debug,$forceReload);
foreach($a_prods as $i_sortOrder =>
$o_prod) {
if ($o_prod->isToShow($checkDate,$checkGroup,$debug,$checkShow,$checkParts)) return TRUE;
* returns the list form for the products under this group
* NOTE: if you have a common produkt structure under this group you can use this
* if not it would be better to use getHTMLProductList and define templates for the product types
// #####################################################################################
// #####################################################################################
if ($debug) echo
"<p><b>PRO_GROUP_NODE::getLinkUrl(...)</b> (".
get_class($this).
")</p>";
echo
"<h1>NOT IMPLEMENTED</h1>";
echo
"<p><b>PRO_GROUP_NODE::getLinkUrl(...)</b> (".
get_class($this).
")</p>";
* returns the <a ... </a> tag for the menu link
function getHTMLLink($valArr=
NULL,$aAddTag=
"",$debug=
FALSE) {
if ($debug) echo
"<p><b>PRO_GROUP_NODE::getHTMLLink($valArr,...)</b> (".
get_class($this).
")</p>";
$uri=
$_SERVER['REQUEST_URI'];
if ((strstr($uri,"PGP_ID=")) &&
(intval($_GET['PGP_ID']))) {
$uri.=
"&PGP_ID=".
$this->getId();
return "<a href=\"$uri\"".
$aAddTag.
">".
$this->PGP_NAME.
"</a>";
// ################################################################
// ################################################################
* returns the html code for the product list
* @param boolean $checkDate
if ($debug) echo
"<p><b>PRO_GROUP_NODE::getHTMLProductList(...)</b> (".
get_class($this).
")</p>";
foreach($productLst as $product) {
if (!empty($this->prodWhere) ||
($product->isToShow($checkDate,$checkGroup,$debug))) {
// if a product where clause is set we asume the
// developer using this knows what he wants therefor we do not need
// to check if the product is to show
$proTag =
$product->getHTMLListRow($checkDate,$checkGroup,$debug);
//$ret.="<div class=\"".$this->LAYOUT_ProductListClass."\" style=\"display:block\">\n";
* returns the html code for the detail page
* $#PRODUCTLIST$ is replaced by a list of all products to show
* @param boolean $checkDate
* @param boolean $checkGroup
* @param string $loginUrl
function getHTMLDetail($checkDate=
TRUE,$checkGroup=
TRUE,$loginUrl=
NULL,$debug=
FALSE) {
if (intval($_GET['PGPDEBUG'])) $debug=
TRUE;
if ($debug) echo
"<p><b>PRO_GROUP_NODE::getHTMLDetail(...)</b> (".
get_class($this).
")</p>";
if (strstr($tmpl,"$#PRODUCTLIST$")) {
require_once $GLOBALS['OCSP']['PHPINCPATH'].
"common/pcf_templates.phpinc";
// #####################################################################################
// #####################################################################################
* echos a the row in a table OVERRIDE IN SUB CLASS to change layout
if ($debug) echo
"ID: ".
$this->getId();
* echos a tree intend called by write children
* @param int $expandLevel
echo
"<tr><td><table width='90%' align='right' border='0'>";
$GLOBALS['DBMS_TREE'][$this->getGlobalTreeKey()][$id]->writeTableRowThis($debug);
$GLOBALS['DBMS_TREE'][$this->getGlobalTreeKey()][$id]->writeTableRowChildren($expandLevel-
1,$useCache,$debug);
echo
"</table></td></tr>\n";
// #####################################################################################
// #####################################################################################
* returns the html-code for the sidemenu link
* @todo change to progroup
if ($debug) echo
"<p><b>PRO_GROUP_NODE::getSideMenuLink($class,...)</b> (".
get_class($this).
"/".
$this->getId().
")";
return "Link To ".
$this->PGP_TITLE.
" not implemented (PRO_GROUP_NODE::getSideMenuLink())";
* @param string $class css-style class to use for <a>
if ($debug) echo
"<p><b>PRO_GROUP_NODE::writeSideMenuRow($class,$debug)</b> (".
get_class($this).
")</p>";
* writes a sidemneu row on Path to the selected node
* @param string $class css-style class to use for <a>
if ($debug) echo
"<tr><td><b>PRO_GROUP_NODE::writeSideMenuRowOnPath($path,$class,$debug)</b> (".
get_class($this).
")</td></tr>";
echo
"<tr><td align=\"right\">";
echo
$this->subtblTag.
"\n";
array_shift($treePath); // remove the first id (points to $this)
$node->subtblTag=
$this->subtblTag;
$node->trTag =
"\t".
$this->trTag;
$node->tdTag =
$this->tdTag;
$node->pageUrl =
$this->pageUrl;
if ((!is_object($treePath[0])) ||
($id !=
$treePath[0]->getId())) {
if ($node->isToShow(TRUE,TRUE,$debug)) {
$node->writeSideMenuRow("",$debug);
$node->writeSideMenuRowOnPath($treePath,"",$debug);
echo
"</table></td></tr>\n";
} // class PRO_GROUP_NODE
Documentation generated on Thu, 08 Jan 2009 17:48:07 +0100 by phpDocumentor 1.4.0a2