Source for file PRO_GROUP.phpclass
Documentation is available at PRO_GROUP.phpclass
* openCSP class file PRO_GROUP.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: PRO_GROUP.phpclass,v 1.9 2008/10/16 02:21:48 pitlinz Exp $
// ---------------------------------------------------------
// ---------------------------------------------------------
* openCSP class PRO_GROUP
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: PRO_GROUP.phpclass,v 1.9 2008/10/16 02:21:48 pitlinz Exp $
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @constant string CLASS_SRC_FILE
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** class vars ------------------------------------------------------ */
* unit of work of loaded product groups
* @var array $loadedNodes
protected static $loadedNodes=
array();
/*** class methods --------------------------------------------------- */
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** compostion --------------------------------------------------- */
* products assigned to the group
/*** attributes -------------------------------------------------- */
* @var double $childrenPopulateTS
* @var string $myProductTable
* @var double $productPopulateTS
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* factory a product group
return self::factoryFromDBRow($arr_row);
* factory a product group from an db row
* returns a product group in $self::loadedNodes
if (!isset
(self::$loadedNodes[$aId]) ||
!pcf_is_instance_of(self::$loadedNodes[$aId],'PRO_GROUP'))
if (!(self::$loadedNodes[$aId] =
self::factoryFromId($aId)))
return self::$loadedNodes[$aId];
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* returns the pro group id
* sets the product group id
public function setId($aId)
* returns the sort order number
* returns the title if set otherwise the name
public function getTitle($langId=
0,$debug=
False)
// -------------------------------------------------------
// db save methods (insert / replace (update) / delete)
// -------------------------------------------------------
* inserts a new row to the table
* @param boolean $debug show debug info
* @returns int returns the autoIncFld ID if exists or 1 on success
self::$loadedNodes[$this->getId()] =
$this;
// -------------------------------------------------------
// -------------------------------------------------------
$arr_ret[] =
$this->getId();
$arr_ret =
array($this->getId());
* returns if the product group has children
* populates $this->myChildren
foreach($arr_children as $arr_row)
$int_sort =
(intval($arr_row['PGP_SORTORDER']) ?
intval($arr_row['PGP_SORTORDER']) :
1);
while(isset
($this->myChildren[$int_sort])) $int_sort++
;
if (isset
(self::$loadedNodes[$arr_row['PGP_ID']]))
$this->myChildren[$int_sort] =
&self::$loadedNodes[$arr_row['PGP_ID']];
$this->myChildren[$int_sort]->setDBField('PGP_SORTORDER',$int_sort);
self::$loadedNodes[$arr_row['PGP_ID']] =
PRO_GROUP_TYPE::factoryFromId(intval($arr_row['PGT_ID']))->factoryProGroupFromRow($arr_row);
$this->myChildren[$int_sort] =
&self::$loadedNodes[$arr_row['PGP_ID']];
$this->myChildren[$int_sort]->setDBField('PGP_SORTORDER',$int_sort);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,sizeof($this->myChildren) .
" children populated");
* returns an array with the children
// -------------------------------------------------------
// -------------------------------------------------------
* populates the products and sets $this->productPopulateTS
foreach($arr_products as $arr_row)
//if ($debug) echoDebugLine(__FILE__,__LINE__,"<pre>" . print_r($arr_row,True) . "</pre>");
* returns an array of all products in the product group
* NOTE: this method uses the T_PRO_PRODGROUP table
* take care this table is up to date
$str_query =
"SELECT * FROM T_PRO_PRODUCT ";
$str_query.=
" WHERE PRO_ID IN (";
$str_query.=
" SELECT PRO_ID FROM T_PRO_PRODGROUP ";
$str_query.=
" WHERE PRO_ID = " .
$this->getId();
$str_query.=
" AND PRO_PGP_ID <> " .
$this->getId();
while ($arr_row =
$obj_cursor->fetchArrayFld())
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Product: {$arr_row['PRO_ID']} found with type {$arr_row['PRT_ID']}");
$this->myProducts[$arr_row['PRO_ID']] =
$obj_type->factoryProductFromRow($arr_row);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"No Type for: <pre>" .
print_r($arr_row,True) .
"</pre>");
* returns an array with all products in the group
* @param PRO_PRODUCT $aProduct
$aProduct->setProGrpId($this->getId());
$this->myProducts[$aProduct->getId()] =
$aProduct;
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* returns if a product is online or not
* @param boolean $checkProducts (check if we have an online part)
* @param boolean $checkParts (force to check product parts)
public function isOnline($checkProducts=
True,$checkParts=
True,$debug=
False)
if ($debug) echoDebugMethod(__FILE__
,get_class($this),"PRO_GROUPS::isOnline(" .
($checkProducts ?
"CHECKPRODUCTS" :
"") .
"," .
($checkParts ?
"CHECKPARTS" :
"") .
")");
$obj_date->setDbString($this->getDBField('PGP_SHOWFROM'));
if ($obj_date->isInFutur())
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"product group will come in future");
$obj_date->setDbString($this->getDBField('PGP_SHOWTILL'));
if ($obj_date->isInPast())
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"product group is out of date");
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"checking products");
foreach($arr_products as &$obj_product)
if ($obj_product->isOnline($checkParts,$debug))
foreach($arr_children as &$obj_child)
if ($obj_child->isOnline($checkProducts,$checkParts,$debug))
* returns if the current user can open the menu
* NOTE: does not dates or PGP_SHOW
* returns if the current user can add a childmenu
* returns if the current user can add a page
* returns if the current user can delete the menu
* returns if the current user can edit the menu
Documentation generated on Thu, 08 Jan 2009 17:48:01 +0100 by phpDocumentor 1.4.0a2