Location: PHPKode > projects > Entier Studio > entierstudio/office/handlers/ctrl.DirectoryProjectUser.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: ctrl.DirectoryProjectUser.php 81 2008-01-17 23:08:21Z yannromefort $
 */
//-------------------------------------------------------------------------
// Safe mode
if (!defined('__ENTIER_FRONT_CONTROLLER__')) die(403);
//
//-------------------------------------------------------------------------
//	Post Handler
//
$projectUser = NULL;
$postback = ($__verb == INSERT_CMD);
$success = true;
//
switch ($__verb) {
    case INSERT_CMD:
        //
        # Insert
        //
        @include_once (COMPONENTS_DATA . "data.DirectoryProjectUser.php");
        //
        $projectUser = new DirectoryProjectUser();
        //
        $projectUser->set_field_value("DIRPROJPKID", $userRequest->Parameter("fkid"));
        $projectUser->set_field_value("DIRUSERPKID", $userRequest->Parameter("pkid"));
        //
        $success = $projectUser->insertRow($database);
        //
        
    break;
    case DELETE_CMD:
        //
        # Delete
        //
        @include_once (COMPONENTS_DATA . "data.DirectoryProjectUser.php");
        //
        $projectUser = new DirectoryProjectUser($userRequest->Parameter("dkey"));
        $success = $projectUser->selectRow($database);
        if (true == $success) {
            $success = $projectUser->deleteRow($database);
        }
        //
        
    break;
}
//
//-------------------------------------------------------------------------
//	View Helper invocation
//
@include_once (COMPONENTS_VIEW . "view.DirectoryProjectUserExplorer.php");
//
$projectUserView = new DirectoryProjectUserExplorer($template, $database);
//
//	Mode Handler
//
$viewMode = NULLVIEW;
$failMode = NULLVIEW;
$viewHTML = "$__ctrl-$__view.html";
$failHTML = "$__ctrl-$__fail.html";
$formMark = "";
//
switch ($__mode) {
    case "form":
        //
        $failMode = FORMVIEW;
        //
        $projectUserView->set_field_value("LOGUSERPKID", $userRequest->Parameter("__user"));
        $projectUserView->set_field_value("DIRUSERPKID", $userRequest->Parameter("pkid"));
        $projectUserView->set_field_value("DIRPROJPKID", $userRequest->Parameter("fkid"));
        $projectUserView->set_field_value("LISTVIEWSRT", $userRequest->Parameter("sort"));
        $projectUserView->set_field_value("LISTVIEWORD", $userRequest->Parameter("ord"));
        //
        
    break;
    case "view":
        //
        $failMode = ITEMVIEW;
        //
        $projectUserView->set_field_value("LOGUSERPKID", $userRequest->Parameter("__user"));
        $projectUserView->set_field_value("DIRPUSRPKID", $userRequest->Parameter("pkid"));
        //
        
    break;
    case "list":
        //
        $failMode = ($__verb == INSERT_CMD) ? FORMVIEW : ITEMVIEW;
        //
        $projectUserView->set_field_value("LOGUSERPKID", $userRequest->Parameter("__user"));
        $projectUserView->set_field_value("DIRUSERPKID", $userRequest->Parameter("pkid"));
        $projectUserView->set_field_value("DIRPROJPKID", $userRequest->Parameter("fkid"));
        $projectUserView->set_field_value("LISTVIEWSRT", $userRequest->Parameter("sort"));
        $projectUserView->set_field_value("LISTVIEWORD", $userRequest->Parameter("ord"));
        //
        
    break;
}
//
//-------------------------------------------------------------------------
//	Error test
if (false == $success) {
    //---------------------------------------------------------------------
    //	Error Handler:
    //
    $projectUserView->set_error_value("DBERRNUMBER", $database->errorNumber());
    $projectUserView->set_error_value("DBERRSTRING", $database->errorString());
    //
    if (is_object($projectUser)) {
        //
        // Check critical errors
        if (($projectUser->get_error_value("DICPROPPKID") == true)) {
            //
            $viewMode = ERROR;
            $viewHTML = "system.errors.html";
        } else {
            //
            // get input errors
            //
            $projectUserView->set_error_value("DATAFIELDSET", $user->fieldSet());
            $projectUserView->set_error_value("DATAERRORSET", $user->errorSet());
            //
            //
            $formMark = "error";
            $viewMode = $failMode;
            $viewHTML = $failHTML;
        }
    }
    //
    //---------------------------------------------------------------------
    
} else {
    //---------------------------------------------------------------------
    //	Reset handler
    if (($postback == true) && ($reset == true)) $template->assign_global("_POSTVERB_", "$__verb");
    //
    //	View Handler
    switch ($__view) {
        case "form":
            //
            if ($userLogin->checkUserRights(AUTH_SITE_SUPER)) $viewHTML = "$__ctrl-$__view.super.html";
            else {
                if ($userLogin->checkUserRights(AUTH_PROJ_CREATE)) $viewHTML = "$__ctrl-$__view.power.html";
                else $viewHTML = "$__ctrl-$__view.guest.html";
            }
            //
            $viewMode = FORMVIEW;
            $formMark = "list";
            //
            break;
        case "view":
            //
            $viewMode = ITEMVIEW;
            //
            break;
        case "pane":
            //
            $viewHTML = "$__ctrl-$__view.html";
            //
            $viewMode = ITEMVIEW;
            //
            break;
        case "list":
            //
            if ($userLogin->checkUserRights(AUTH_SITE_SUPER)) $viewHTML = "$__ctrl-$__view.super.html";
            else {
                if ($userLogin->checkUserRights(AUTH_PROJ_DELETE)) $viewHTML = "$__ctrl-$__view.power.html";
                else $viewHTML = "$__ctrl-$__view.guest.html";
            }
            //
            $viewMode = LISTVIEW;
            $formMark = "list";
            //
            break;
        case "grid":
            //
            $viewHTML = "$__ctrl-$__view.html";
            //
            $viewMode = GRIDVIEW;
            $formMark = "list";
            //
            break;
        }
        //
        //---------------------------------------------------------------------
        
    }
    //-------------------------------------------------------------------------
    //	Display View
    //
    if ($projectUserView->renderView($viewHTML, $formMark, $viewMode) == false) {
        if ($projectUserView->get_error_count() > 0) {
            //
            @include_once (FRAMEWORK_VIEW . "view.ExceptionView.php");
            //
            $exceptionView = new ExceptionView($projectUserView->errorSet());
            $exceptionView->renderView($viewHTML, $formMark, $viewMode);
        }
    }
    //
    //-------------------------------------------------------------------------
    
?>
Return current item: Entier Studio