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