Location: PHPKode > projects > Entier Studio > entierstudio/studio/classes/datas/data.ObjectoryResource.php
<?php
/**
 * Entier Studio
 *
 * LICENSE
 *
 *	Copyright 2006 Entier Studio team.
 *
 *	Licensed under the Apache License, Version 2.0 (the "License");
 *	you may not use this file except in compliance with the License.
 *	You may obtain a copy of the License at
 *
 *		http://www.apache.org/licenses/LICENSE-2.0
 *
 *	Unless required by applicable law or agreed to in writing, software
 *	distributed under the License is distributed on an "AS IS" BASIS,
 *	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *	See the License for the specific language governing permissions and
 *	limitations under the License.
 *
 * @package    entier.studio 
 * @version	   $Id: data.ObjectoryResource.php 81 2008-01-17 23:08:21Z yannromefort $
 * @copyright  Copyright (c) 2006 Entier Studio team. All rights reserved.
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefObjectoryResource")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefObjectoryResource", "1");
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . DATAROWOBJECT);
    @require_once (FRAMEWORK_DIR . "./filters/filter.forminput.php");
    @require_once (FRAMEWORK_DIR . "./filters/filter.locator.resource.php");
    //-------------------------------------------------------------------------
    //	Class
    class ObjectoryResource extends DataRow {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	integer	 pkid	ObjectoryResource		OBJRESOPKID	//	primary key
         *
         */
        function ObjectoryResource($OBJRESOPKID = 0) {
            //
            $this->m_tableSet[PRIMARYKEY] = "tbl_objectory_resource";
            //
            $this->m_indexSet[PRIMARYKEY] = "OBJRESOPKID";
            $this->m_indexSet[FOREIGNKEY] = "DIRRESOPKID";
            $this->m_indexSet[NATURALKEY] = "OBJRESONAME";
            //
            $this->m_fieldSet["OBJRESOPKID"] = $OBJRESOPKID;
        }
        //-------------------------------------------------------------------------
        //	Methods
        
        /**
         *
         * @param	integer	 index type
         * @return	string
         */
        function getInsertQuery($indexType = FOREIGNKEY) {
            //
            $table = $this->m_tableSet[PRIMARYKEY];
            $string = EN_SERVER_CODE;
            //
            $insertSQL = "INSERT INTO $table ( ";
            $valuesSQL = "VALUES ( ";
            //	DIRPROJPKID DirectoryProject		(foreign key)
            $value = $this->m_fieldSet["DIRPROJPKID"];
            if (!empty($value)) {
                $insertSQL.= "  DIRPROJPKID";
                $valuesSQL.= "  $value";
            } else {
                $this->m_errorSet["DIRPROJPKID"] = true;
                return ("");
            }
            //	DIRRESOPKID = DirectoryResource		(foreign key)
            $value = $this->m_fieldSet["DIRRESOPKID"];
            if (!empty($value)) {
                $insertSQL.= " ,DIRRESOPKID";
                $valuesSQL.= " ,$value";
            } else {
                $this->m_errorSet["DIRRESOPKID"] = true;
                return ("");
            }
            //	OBJRESONAME = ObjectoryResource name
            $value = FilterFormInput::filter($this->m_fieldSet["OBJRESONAME"]);
            if (!empty($value)) {
                $insertSQL.= " ,OBJRESONAME";
                $valuesSQL.= " ,$value";
            } else {
                $this->m_errorSet["OBJRESONAME"] = true;
                return ("");
            }
            //	OBJRURLNAME = ObjectoryResource url name
            $value = FilterResourceLocator::filter($this->m_fieldSet["OBJRURLNAME"]);
            if (!empty($value)) {
                $insertSQL.= " ,OBJRURLNAME";
                $valuesSQL.= " ,$value";
            } else {
                $this->m_errorSet["OBJRURLNAME"] = true;
                return ("");
            }
            //	OBJRESOTEXT = ObjectoryResource description
            $value = FilterFormInput::filter($this->m_fieldSet["OBJRESOTEXT"], true);
            if (!empty($value)) {
                $insertSQL.= " ,OBJRESOTEXT";
                $valuesSQL.= " ,$value";
            }
            //	OBJRURLHOST  = ObjectoryResource host name
            $value = @trim($this->m_fieldSet["OBJRURLHOST"]);
            if (!empty($value)) {
                $insertSQL.= " ,OBJRURLHOST";
                $valuesSQL.= " ,\"$value\"";
            } else {
                $this->m_errorSet["OBJRURLHOST"] = true;
                return ("");
            }
            //	OBJRURLPORT  = ObjectoryResource port number
            $value = $this->m_fieldSet["OBJRURLPORT"];
            if (!empty($value)) {
                $insertSQL.= " ,OBJRURLPORT";
                $valuesSQL.= " ,$value";
            }
            //	OBJRURLUSER = ObjectoryResource user name
            $value = FilterFormInput::filter($this->m_fieldSet["OBJRURLUSER"], true);
            if (!empty($value)) {
                $insertSQL.= " ,OBJRURLUSER";
                $valuesSQL.= " ,$value";
            }
            //	OBJRURLPASS = ObjectoryResource password
            $value = FilterFormInput::filter($this->m_fieldSet["OBJRURLPASS"], true);
            if (!empty($value)) {
                $insertSQL.= " ,OBJRURLPASS";
                $valuesSQL.= " ,AES_ENCRYPT($value,'$string')";
            }
            //	OBJRESODATE = ObjectoryResource creation date
            $value = Date("Y-m-d H:i:s");
            $insertSQL.= " ,OBJRESODATE";
            $valuesSQL.= " ,\"$value\"";
            //	OBJRESOSTAT = ObjectoryResource status
            $value = 1;
            $insertSQL.= " ,OBJRESOSTAT";
            $valuesSQL.= " ,$value";
            //	OBJRESOTYPE = ObjectoryResource type
            $value = $this->m_fieldSet["OBJRESOTYPE"];
            if (!empty($value)) {
                $insertSQL.= " ,OBJRESOTYPE";
                $valuesSQL.= " ,$value";
            }
            //
            return ($insertSQL . ") " . $valuesSQL . ")");
        }
        /**
         *
         * @param	integer	 index type
         * @return	string
         */
        function getUpdateQuery($indexType = PRIMARYKEY) {
            //
            $table = $this->m_tableSet[PRIMARYKEY];
            $string = EN_SERVER_CODE;
            //
            switch ($indexType) {
                case PRIMARYKEY:
                    //
                    $field = $this->m_indexSet[PRIMARYKEY];
                    $index = $this->m_fieldSet["$field"];
                    if ($index != 0) {
                        //
                        $updateSQL = "UPDATE $table SET ";
                        //	OBJRESONAME = ObjectoryResource name
                        $value = FilterFormInput::filter($this->m_fieldSet["OBJRESONAME"]);
                        if (!empty($value)) $updateSQL.= " OBJRESONAME=$value";
                        else {
                            $this->m_errorSet["OBJRESONAME"] = true;
                            return ("");
                        }
                        //	OBJRURLNAME = ObjectoryResource user name
                        $value = FilterResourceLocator::filter($this->m_fieldSet["OBJRURLNAME"]);
                        if (!empty($value)) $updateSQL.= ",OBJRURLNAME=$value";
                        else {
                            $this->m_errorSet["OBJRURLNAME"] = true;
                            return ("");
                        }
                        //	OBJRURLHOST  = ObjectoryResource host name
                        $value = $this->m_fieldSet["OBJRURLHOST"];
                        if (!empty($value)) $updateSQL.= ",OBJRURLHOST=\"$value\"";
                        else {
                            $this->m_errorSet["OBJRURLHOST"] = true;
                            return ("");
                        }
                        //	OBJRESOTEXT = ObjectoryResource description
                        $value = FilterFormInput::filter($this->m_fieldSet["OBJRESOTEXT"], true);
                        $updateSQL.= ",OBJRESOTEXT=$value";
                        //	OBJRURLPORT  = ObjectoryResource host name
                        $value = $this->m_fieldSet["OBJRURLPORT"];
                        if (!empty($value)) $updateSQL.= ",OBJRURLPORT=$value";
                        //	OBJRURLUSER = ObjectoryResource user name
                        $value = FilterFormInput::filter($this->m_fieldSet["OBJRURLUSER"], true);
                        $updateSQL.= ",OBJRURLUSER=$value";
                        //	OBJRURLPASS = ObjectoryResource password
                        $value = FilterFormInput::filter($this->m_fieldSet["OBJRURLPASS"], true);
                        $updateSQL.= ",OBJRURLPASS=AES_ENCRYPT($value,'$string')";
                        //	OBJRESOSTAT = ObjectoryResource status
                        $value = $this->m_fieldSet["OBJRESOSTAT"];
                        $updateSQL.= ",OBJRESOSTAT=$value";
                        //
                        return ($updateSQL . " WHERE $field=$index");
                    }
                    break;
                case DISPLAYKEY:
                    /*
                    *	UPDATE
                    *			tbl_objectory_resource
                    *	SET
                    *			OBJRESONAME='OBJRESOPKID'
                    *			OBJRESOSTAT=0
                    *	ON
                    *			OBJRESOPKID
                    *
                    */
                    //
                    $field = $this->m_indexSet[PRIMARYKEY];
                    $index = $this->m_fieldSet["$field"];
                    if ($index != 0) return ("UPDATE 
									$table 
								SET 
									OBJRESONAME= CONCAT('~', OBJRESONAME, '$index' ),
									OBJRESOSTAT=0 
								WHERE 
									$field=$index 
								AND 
									OBJRESOSTAT=1");
                    break;
                }
                //
                return ("");
            }
            /**
             *
             * @param	integer	 index type
             * @return	string
             */
            function getSelectQuery($indexType = PRIMARYKEY) {
                //
                $string = EN_SERVER_CODE;
                //
                switch ($indexType) {
                    case PRIMARYKEY:
                        /*
                        *
                        *	SELECT
                        *			tbl_objectory_resource			as t1
                        *		<-> tbl_directory_resource			as t2
                        *		<-> tbl_directory_resource_access	as t3
                        *	ON OBJRESOPKID
                        *
                        */
                        //
                        $field = $this->m_indexSet["$indexType"];
                        $index = $this->m_fieldSet["$field"];
                        //
                        if ($index != 0) return ("SELECT 
									t1.OBJRESOPKID,
									t1.DIRPROJPKID,
									t1.DIRRESOPKID,
									t1.OBJRESONAME,
									t1.OBJRESOTEXT,
									t1.OBJRURLNAME,
									t1.OBJRURLHOST,
									t1.OBJRURLPORT,
									t1.OBJRURLUSER,
									AES_DECRYPT( t1.OBJRURLPASS,'$string') as OBJRDECPASS,
									t1.OBJRESOTIME,
									t1.OBJRESODATE,
									t1.OBJRESOSTAT,
									t1.OBJRESOTYPE,
									t2.DIRECTOPKID,
									t2.DIRRESTPKID,
									t2.DIRRACCPKID,
									t2.DIRRESONAME,
									t3.DIRRACCCODE
								FROM
									tbl_objectory_resource			as t1,
									tbl_directory_resource			as t2,
									tbl_directory_resource_access	as t3
								WHERE
									t1.OBJRESOPKID=$index
								AND
									t1.OBJRESOSTAT > 0
								AND
									t1.DIRRESOPKID=t2.DIRRESOPKID
								AND
									t2.DIRRACCPKID=t3.DIRRACCPKID");
                        //
                        break;
                    }
                    //
                    return ("");
            }
        };
        //	Class
        //-------------------------------------------------------------------------
        
    }
    //	namespace
    //-----------------------------------------------------------------------------
    
?>
Return current item: Entier Studio