Location: PHPKode > projects > Entier Studio > entierstudio/office/classes/views/view.DirectoryUserExplorer.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.office
 * @copyright  Copyright (c) 2006 Entier Studio team. All rights reserved.
 * @version	   $Id: view.DirectoryUserExplorer.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-----------------------------------------------------------------------------
//	namespace
if (!defined("DefDirectoryUserExplorer")) {
    //-------------------------------------------------------------------------
    //	Define
    define("DefDirectoryUserExplorer", "1");
    define(ROOTVIEW, 10);
    //-------------------------------------------------------------------------
    //	Include
    @require_once (FRAMEWORK_DIR . VIEWHELPER);
    //-------------------------------------------------------------------------
    //	Class
    class DirectoryUserExplorer extends ViewObject {
        //---------------------------------------------------------------------
        //	Constructor
        
        /**
         *
         * @param	object	Instance of ViewTemplate
         * @param	object	Instance of DataSource
         */
        function DirectoryUserExplorer($template, $database) {
            //
            parent::ViewObject($template, $database);
        }
        //---------------------------------------------------------------------
        //	Methods
        
        /**
         *
         * @access	public
         *
         * @return	object
         */
        function getObject() {
            //
            @include_once (COMPONENTS_DATA . "data.DirectoryUser.php");
            //
            return (new DirectoryUser);
        }
        /**
         *
         * @access	public
         *
         * @param	string	layout name is a template file name or a layer name in a template file
         * @param	string	block name in layout
         * @param	integer	view type	{ ITEMVIEW, LISTVIEW, TREEVIEW }
         * @param	integer	outputmode
         * @return	boolean
         */
        function renderView($layout, $block = NULL, $view = NULL, $mode = OUTPUT) {
            //
            if (!is_object($this->Template())) {
                //
                $this->m_errorSet[VIEW_SYSTEM_ERROR] = true;
                //
                return (false);
            }
            //
            if (isset($layout) && ($this->m_Template->define($layout) == false)) {
                //
                $this->m_errorSet[VIEW_LAYOUT_ERROR] = $layout;
                //
                return (false);
            }
            //
            /*
            * *- Error management
            */
            //
            if ($this->get_error_count() > 0) {
                //
                include_once (FRAMEWORK_VIEW . "view.ErrorMessage.php");
                //
                $errorMessage = new ErrorMessage($this->errorSet());
                if ($errorMessage->renderView($this->m_Template, $block, $view) == false) {
                    //
                    $this->m_errorSet[VIEW_RENDER_ERROR] = true;
                    //
                    return (false);
                }
            }
            //
            @include_once (COMPONENTS_DATA . "data.DirectoryUser.php");
            //
            switch ($view) {
                case FORMVIEW:
                    /*
                    * @see handler ctrl.DirectoryUser-form.php
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    * 2- DirectoryOrganisationSet
                    * 3- ApplicationCodificationSet
                    */
                    //
                    $user = new DirectoryUser($this->m_fieldSet["LOGUSERPKID"]);
                    if ($user->selectRow($this->Database()) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_Template->assign($user->fieldSet());
                    //
                    /*
                    * 2- DirectoryOrganisationSet Dropdownlist
                    */
                    //
                    if ($user->get_authorization(AUTH_SITE_SUPER)) {
                        //
                        @include_once (COMPONENTS_DATA . "data.DirectoryUnitSet.php");
                        //
                        $organizationSet = new DirectoryUnitSet($user->get_field_value("DIRECTOPKID"));
                        if ($organizationSet->selectSet($this->Database()) == false) {
                            //
                            $this->m_errorSet[HTML_OBJECT_ERROR] = true;
                            //
                            return (false);
                        }
                        //
                        @include_once (FRAMEWORK_DIR . "htmldropdownlist.php");
                        //
                        $organizationSetDDL = new HTMLDropdownList("fkid", "formInput");
                        $this->m_blockSet["DIRUNITLIST"] = $organizationSetDDL->renderObject($this->Database() , $organizationSet, $user->get_field_value("DIRUNITPKID"));
                        //
                        unset($organizationSetDDL);
                        unset($organizationSet);
                    }
                    //
                    /*
                    * 3- ApplicationCodificationSet Dropdownlist
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet["DIRSTATLIST"] = $codificationSetDDL->renderObject($this->Database() , $codificationSet, 1);
                    //
                    unset($codificationSetDDL);
                    unset($codificationSet);
                    //
                    $this->m_Template->assign($this->m_fieldSet);
                    $this->m_Template->assign($this->m_blockSet);
                    //
                    
                break;
                case ITEMVIEW:
                    /*
                    * @see handler ctrl.DirectoryUser-view.php
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    * 2- ApplicationCodificationSet
                    * 3- AuthorizationSet
                    */
                    //
                    $user = new DirectoryUser($this->m_fieldSet["DIRUSERPKID"]);
                    if ($user->selectRow($this->Database()) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_Template->assign($user->fieldSet());
                    //
                    /*
                    * 2- ApplicationCodificationSet
                    */
                    //
                    @include_once (COMPONENTS_HTML . "html.ApplicationCodificationDDL.php");
                    //
                    $codificationSet = NULL;
                    $codificationSetDDL = new ApplicationCodificationDDL("stat", "formInput", 1);
                    $this->m_blockSet["DIRSTATLIST"] = $codificationSetDDL->renderObject($this->Database() , $codificationSet, $user->get_field_value("DIRUSERSTAT"));
                    //
                    unset($codificationSetDDL);
                    unset($codificationSet);
                    //
                    /*
                    * 2- ApplicationCodificationSet
                    */
                    //
                    $DIRUSERAUTH = $user->get_field_value("DIRUSERAUTH");
                    // Create rights
                    if ($user->get_authorization(AUTH_USER_CREATE)) $this->m_blockSet["AUTH_USER_CREATE"] = "checked";
                    //
                    if ($user->get_authorization(AUTH_PROJ_CREATE)) $this->m_blockSet["AUTH_PROJ_CREATE"] = "checked";
                    //
                    if ($user->get_authorization(AUTH_ORGN_CREATE)) $this->m_blockSet["AUTH_ORGN_CREATE"] = "checked";
                    // Modify rights
                    if ($user->get_authorization(AUTH_USER_MODIFY)) $this->m_blockSet["AUTH_USER_MODIFY"] = "checked";
                    //
                    if ($user->get_authorization(AUTH_PROJ_MODIFY)) $this->m_blockSet["AUTH_PROJ_MODIFY"] = "checked";
                    //
                    if ($user->get_authorization(AUTH_ORGN_MODIFY)) $this->m_blockSet["AUTH_ORGN_MODIFY"] = "checked";
                    // Delete rights
                    if ($user->get_authorization(AUTH_USER_DELETE)) if (($DIRUSERAUTH&AUTH_USER_DELETE) || ($DIRUSERAUTH == AUTH_SITE_SUPER)) $this->m_blockSet["AUTH_USER_DELETE"] = "checked";
                    //
                    if ($user->get_authorization(AUTH_PROJ_DELETE)) $this->m_blockSet["AUTH_PROJ_DELETE"] = "checked";
                    //
                    if ($user->get_authorization(AUTH_ORGN_DELETE)) $this->m_blockSet["AUTH_ORGN_DELETE"] = "checked";
                    // Super user
                    $this->m_Template->toggle("super", $user->get_authorization(AUTH_SITE_SUPER));
                    //
                    $this->m_Template->assign($this->m_fieldSet);
                    $this->m_Template->assign($this->m_blockSet);
                    //
                    break;
                case LISTVIEW:
                    /*
                    * @see handler ctrl.DirectoryUser-list.php
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    * 2- DirectoryUserSet
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryUser.php");
                    //
                    $user = new DirectoryUser($this->m_fieldSet["LOGUSERPKID"]);
                    if ($user->selectRow($this->Database()) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_Template->assign($user->fieldSet());
                    $this->m_Template->assign($this->m_fieldSet);
                    //
                    $this->m_Template->toggle("create", $user->get_authorization(AUTH_USER_CREATE));
                    //
                    /*
                    * 2- DirectoryUserSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryUserSet.php");
                    //
                    $userSet = new DirectoryUserSet($user->get_field_value("DIRUNITPKID") , $user->get_field_value("DIRECTOPKID"));
                    if ($userSet->selectSet($this->Database() , ($user->get_authorization(AUTH_SITE_SUPER)) ? DEFAULTKEY : FOREIGNKEY, $this->m_fieldSet["LISTVIEWSRT"], $this->m_fieldSet["LISTVIEWORD"]) == true) {
                        //
                        for ($i = 0;$i < $userSet->rowCount();$i++) {
                            //	select row
                            if ($userSet->fetchCursorRow($this->Database()) == false) return (false);
                            //
                            $this->m_Template->select($block);
                            $this->m_Template->assign($userSet->fieldSet());
                            $this->m_Template->render($block);
                        }
                    }
                    //
                    break;
                case GRIDVIEW:
                    /*
                    * @see handler ctrl.DirectoryUser-list.php
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    * 2- DirectoryUserSet
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryUser.php");
                    //
                    $user = new DirectoryUser($this->m_fieldSet["LOGUSERPKID"]);
                    if ($user->selectRow($this->Database()) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_Template->assign($user->fieldSet());
                    $this->m_Template->assign($this->m_fieldSet);
                    //
                    /*
                    * 2- DirectoryUserSet
                    */
                    //
                    @include_once (COMPONENTS_DATA . "data.DirectoryUserSet.php");
                    //
                    $userSet = new DirectoryUserSet($this->m_fieldSet["DIRUNITPKID"]);
                    if ($userSet->selectSet($this->Database() , FOREIGNKEY, $this->m_fieldSet["LISTVIEWSRT"], $this->m_fieldSet["LISTVIEWORD"]) == true) {
                        //
                        for ($i = 0;$i < $userSet->rowCount();$i++) {
                            //	select row
                            if ($userSet->fetchCursorRow($this->Database()) == false) return (false);
                            //
                            $this->m_Template->select($block);
                            $this->m_Template->assign($userSet->fieldSet());
                            $this->m_Template->render($block);
                        }
                    }
                    //
                    break;
                case FRAMEVIEW:
                    /*
                    * * @see handler ctrl.DirectoryUser-frame.php
                    */
                    //
                    /*
                    * 1- DirectoryUser
                    */
                    //
                    $user = new DirectoryUser($this->m_fieldSet["DIRUSERPKID"]);
                    if ($user->selectRow($this->Database()) == false) {
                        //
                        $this->m_errorSet[VIEW_OBJECT_ERROR] = true;
                        //
                        return (false);
                    }
                    //
                    $this->m_Template->assign($user->fieldSet());
                    $this->m_Template->assign($this->fieldSet());
                    //
                    break;
                }
                //
                $this->m_Template->output($mode);
                //
                return (true);
            }
        };
        //	Class
        //-------------------------------------------------------------------------
        
    }
    //	namespace
    //-----------------------------------------------------------------------------
    
?>
Return current item: Entier Studio