<?php

/**
 * @package FrontEnds
 * @subpackage MVC
 */
include_once $cfg['DBAL']['dir']['root'] . '/Database.class.php';
//include_once($cfg['Auth']['dir']['root'] . '/Auth.class.php');
//in/lude_once($cfg['Auth']['dir']['root'] . '/AuthUtil.class.php');
MVCUtils::includeModel('TemplateModel', 'MVC');
/**
 * Model for template management
 */
class AddTemplateModel extends TemplateModel
{
    const module = 'MVCFrontEnd';
    protected function processValid()
    {
        if (isset($this->fieldData['submit'])) {
            global $cfg;
            $db = Database::getInstance($cfg['MVC']['dsn']);
            $insertArray = array('filename' => $this->fieldData['fileName'], 'modelclassname' => $this->fieldData['modelName'], 'viewerclassname' => $this->fieldData['viewerName']);
            $db->insert('templates', $insertArray);
        }
    }
    protected function processInvalid()
    {
        //No invalid processing required
    }
    protected function listPHPClassFiles($path, $recursive)
    {
<?php

/**
 * @package DPS
 */
include_once $cfg['DBAL']['dir']['root'] . '/Database.class.php';
include_once $cfg['MVC']['dir']['root'] . '/MVCUtils.class.php';
MVCUtils::includeModel('Model', 'tkfecommon');
/**
 * Model for user management
 */
class DPSUserDeleteShowItemModel extends Model
{
    const module = 'DPS';
    protected function processValid()
    {
        global $cfg;
        $db = Database::getInstance($cfg['DPS']['dsn']);
        $itemID = pg_escape_string($this->fieldData['itemID']);
        $sql = "SELECT showplanid FROM showitems WHERE id = {$itemID}";
        $showID = $db->getOne($sql);
        $sql = "SELECT * FROM showitems \n\t\t\tWHERE showplanid = {$showID} ORDER BY position ASC";
        $showItems = $db->getAll($sql);
        $delled = false;
        foreach ($showItems as $item) {
            if ($delled) {
                $where = "showplanid = {$showID} and id = " . $item['id'];
                $update['position'] = $item['position'] - 1;
                $db->update('showitems', $update, $where, true);
            }
            if ($item['id'] == $itemID) {
 /**
  * Initialise the model
  *
  * Will initialise the model class. The class name is stored in the 
  * $modelClassName class variable.
  * 
  * @return Model Returns the initialised model for use if required
  */
 public static function initializeModel($templateIDS, $formName = null, $modelModuleName, $viewerModuleName, $fieldData = array(), $errors = array())
 {
     global $cfg;
     if (isset($fieldData['moduleName'])) {
         $modelClassName = MVCUtils::getModelClassNameFromDB($formName, $fieldData['moduleName']);
         MVCUtils::includeModel($modelClassName, $modelModuleName);
     } else {
         $modelClassName = MVCUtils::getModelClassNameFromDB();
         MVCUtils::includeModel($modelClassName, $modelModuleName);
     }
     $pathParts = pathinfo($modelClassName);
     $realClassName = $pathParts['basename'];
     eval("\$model = new " . $realClassName . "(\$templateIDS, \$formName, \$modelModuleName, \$viewerModuleName, \$fieldData, \$errors);");
     return $model;
 }