Source for file CLI_TYPE.phpclass
Documentation is available at CLI_TYPE.phpclass
* Class file CLI_TYPE.phpclass
* @project Open CSP-Management
* @author Peter Krebs <p.krebs@wpus.at>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: CLI_TYPE.phpclass,v 1.12 2008/12/02 15:08:57 peterkrebs Exp $
// -------------------------------------------
// -------------------------------------------
require_once __OCSP_DEFAULTCONFPATH__.
"client.conf.phpinc";
* Class file CLI_TYPE.phpclass
* @project Open CSP-Management
* @author Peter Krebs <p.krebs@wpus.at>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: CLI_TYPE.phpclass,v 1.12 2008/12/02 15:08:57 peterkrebs Exp $
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @constant string CLASS_SRC_FILE
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** class vars ------------------------------------------------------ */
* @staticvar array $myStaffList
protected static $loadedCliTypes =
array();
/*** class methods --------------------------------------------------- */
* returns an instance out of the identity map
if (!isset
(self::$loadedCliTypes[$aId]))
self::$loadedCliTypes[$aId] =
self::factoryFromId($aId,$debug);
return self::$loadedCliTypes[$aId];
* returns an array with all instances
if ($debug) echoDebugMethod(__FILE__
,"static","CLI_TYPE::getAllInstances()",print_r($filter,True));
//$arr_ret[0] = self::getInstance(0);
foreach($arr_typeRows as $arr_row)
self::$loadedCliTypes[intval($arr_row['CTY_ID'])] =
new CLI_TYPE();
self::$loadedCliTypes[intval($arr_row['CTY_ID'])]->setDBRow($arr_row,True);
$arr_ret[intval($arr_row['CTY_ID'])] =
&self::$loadedCliTypes[intval($arr_row['CTY_ID'])];
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @staticvar string $myTable name of the db table
* unit of work address objects
* @staticvar array $clientTypeLst
static $clientTypeLst =
array();
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
$obj_ret->setId(intval($aId));
* init the object and populate if an id is submitted
* @param int $cliId CLI_ID
function CLI_TYPE($ctyId=
0,$debug=
False) {
* returns the name of the staff
if (!($str_name =
$this->getDBField('CTY_NAME')) ||
empty($str_name))
if ($this->getid() ==
0) $str_name =
t_admin('Default');
* in future it is planed to be able to split the clients into more than one table
* therefore the type must know wher to search
* returns if the type has profiles enabled
* @param boolean $doDBCheck check if there are also profiles defined in the databas
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_WARNING);
$s_query=
"SELECT COUNT(*) FROM T_CLI_PROFILES WHERE CLP_KEYTABLE='T_CLI_CLIENT' AND (CTY_ID=".
$this->getId().
" OR CTY_ID=0)";
if ($debug) echoDebug(__FILE__
,"<p>Checking DB: $s_query</p>");
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* includes the client class source file
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Class Source: " .
$s_Src);
if ($debug) echoDebug(__FILE__
,"Source: ".
$s_Src);
* returns the class name of the client object defined by the type
* and ensures the class exists
if (empty($s_className)) {
return (class_exists($s_className) ?
$s_className :
"CLIENT");
* generates a new client object with this type
* @return CLIENT or an instance of it
$s_cmd=
"\$o_client=new ".
$s_className.
"();";
$o_client->setDBRow($cliRow,(intval($cliRow['CLI_ID']) ?
True:
False),$debug);
$o_client->setTypeObj($this);
* factories a client from an id
$obj_client =
new $str_className();
$obj_client->setTypeObj($this);
if ($obj_client->getTypeId() ==
$this->getId())
$arr_filter =
array('CLI_ID' =>
intval($aId));
$obj_client =
new $str_className();
$obj_client->setTypeObj($this);
// ------------------------------------------------------
// ------------------------------------------------------
* returns if the client type has staffs enabled
* returns the first staff type in T_CLI_STAFF_TYPE fits for this type
* <code>SELECT * FROM T_CLI_STAFF_TYPE WHERE CTY_ID IN($this->getId(),0) ORDER BY CTY_ID DESC,CSTTYPE_SORTORDER</code>;
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
$o_staType->setDBObj($this->getDBObj());
$s_query =
"SELECT * FROM T_CLI_STAFF_TYPE ";
$s_query.=
" WHERE CTY_ID IN(".
$this->getId().
",0)";
$s_query.=
" ORDER BY CTY_ID DESC,CSTTYPE_SORTORDER";
if ($a_row=
$this->myDBObj->quickQuery($s_query)) {
$o_staType->setDBRow($a_row,True,$debug);
$o_staType->setClientTypeObj($this);
* if $typeId is 0 $this->getDefaultStaffType is returned
// ------------------------------------------------------
// ------------------------------------------------------
* returns the interests for available
if ($arr_instances =
INTEREST::getAllInstances())
foreach($arr_instances as $int_id =>
&$obj_node)
if (!$obj_node->isRoot())
if (($obj_node->getCliTypeId() ==
$this->getId()) ||
($obj_node->getCliTypeId() ==
0))
$arr_ret[$int_id] =
&$obj_node;
// ------------------------------------------------------
// ------------------------------------------------------
* returns if the current user can show clients of this type
* returns if the current user can edit clients of this type
* returns if the current user can delete clients of this type
if ($debug) echoDebug(__FILE__
,"<p>User isMember of ".
$i_grp_id.
"</p>");
* returns if the current user can delete clients of this type
if ($debug) echoDebug(__FILE__
,"<p>User isMember of ".
$i_grp_id.
"</p>");
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"User not member of " .
$i_grp_id);
* return if a user can edit his own client data
// ------------------------------------------------------
// ------------------------------------------------------
* sets the forms DBMS_TABLEOBJ
* @param CLI_FORM $frmObj
if ((!empty($s_className)) &&
file_exists($GLOBALS['PROJECT']['PATH'].
$this->getDBField('CTY_CLASSFILE'))) {
$frmObj->myDBMS_TABLEOBJ_include=
$GLOBALS['PROJECT']['PATH'].
$this->getDBField('CTY_CLASSFILE');
$frmObj->myDBMS_TABLEOBJ_class =
$s_className;
$frmObj->myDBMS_TABLEOBJ_include=
dirname(__FILE__
).
"/CLIENT.phpclass";
$frmObj->myDBMS_TABLEOBJ_class =
"CLIENT";
* returns the form used in admin section
* @param boolean $frmMode
function &getAdminForm($frmMode=
FRM_MODE_READONLY,$debug=
False) {
if ($debug) echoDebug(__FILE__
,"<p>USING TABLEDEFAULT T_CLI_CLIENT</p>");
if (!is_object($o_frmObj)) return $o_frmObj; // NULL
$o_frmObj->setFrmMode($frmMode);
* returns the form used in admin section
* @param boolean $frmMode
function &getUserForm($frmMode=
FRM_MODE_READONLY,$debug=
False) {
if ($debug) echoDebug(__FILE__
,"<p>USING TABLEDEFAULT T_CLI_CLIENT</p>");
if (!is_object($o_frmObj)) return $o_frmObj; // NULL
$o_frmObj->setFrmMode($frmMode);
* returns the address form id
* returns the address form object
* returns the form used in admin section
* @param boolean $frmMode
if ($obj_form->formIsLoaded())
$obj_form->setFrmMode($frmMode);
if ($obj_form =
$obj_staffType->getListForm() &&
$obj_form->formIsLoaded())
$obj_form->setFrmMode($frmMode);
if ($debug) echoDebug(__FILE__
,"<p>USING TABLEDEFAULT T_CLI_STAFF</p>");
if (!$obj_form->formIsLoaded())
$o_frmObj->setFrmMode($frmMode);
* returns the form used to handele values in T_CLI_USER AND T_SYS_USER
* if no form id is set the default form for T_SYS_USER is returned
Documentation generated on Thu, 08 Jan 2009 17:38:29 +0100 by phpDocumentor 1.4.0a2