[ffl-cvs] ffl/class Position.php,NONE,1.1
Status: Inactive
Brought to you by:
rizzo
From: Don S. <ri...@us...> - 2004-07-28 19:19:51
|
Update of /cvsroot/ffl/ffl/class In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9625/class Added Files: Position.php Log Message: Updates --- NEW FILE: Position.php --- <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * FFL * * See docs/AUTHORS and docs/COPYRIGHT for relevant info. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @version $Id: Position.php,v 1.1 2004/07/28 19:19:43 rizzo Exp $ */ require_once(PHPWS_SOURCE_DIR . "core/Item.php"); require_once(PHPWS_SOURCE_DIR . "core/EZform.php"); require_once(PHPWS_SOURCE_DIR . "core/Text.php"); require_once(PHPWS_SOURCE_DIR . "core/Message.php"); /** * Position object for FFL * * @package ffl * @version $Id: Position.php,v 1.1 2004/07/28 19:19:43 rizzo Exp $ * @author Don Seiler <do...@se...> * @access public */ class FFL_Position extends PHPWS_Item { /** * The abbreviation/code of the position * * @var string * @access private */ var $_abbrname = NULL; function FFL_Position($POSITION_ID = NULL) { /* These vars are excluded on commit() */ // $exclude = array(); // $this->addExclude($exclude); $this->setTable("mod_ffl_positions"); if (is_numeric($POSITION_ID)) { $this->setId($POSITION_ID); $this->init(); } elseif (is_array($POSITION_ID)) { $this->init($POSITION_ID); } }// END FUNC FFL_Position function _edit() { if (!$_SESSION["OBJ_user"]->allow_access("ffl","edit_positions")) { $message = $_SESSION["translate"]->it("Access to edit positions was denied due to lack of proper permissions."); $error = new PHPWS_Error("ffl", "FFL_Position::_edit()", $message, "exit", 1); $error->message(); return FALSE; } /* Create form */ $form = new EZform("FFL_Position_edit"); /* Position Name */ $form->add("Position_fullname", "text", $this->getLabel()); $form->setSize("Position_fullname", 33); $form->setTab("Position_fullname", 1); /* Position Abbreviation */ $form->add("Position_abbrname", "text", $this->_abbrname); $form->setSize("Position_abbrname", 5); $form->setTab("Position_abbrname", 2); /* Save Button */ $form->add("Position_save", "submit", $_SESSION["translate"]->it("Save")); $form->setTab("Position_save", 3); /* Module Information */ $form->add("module", "hidden", "ffl"); $form->add("FFL_POSITION_OP", "hidden", "save"); $tags = array(); $tags = $form->getTemplate(); $tags["FULLNAME_TEXT"] = $_SESSION["translate"]->it("Position Name"); $tags["ABBRNAME_TEXT"] = $_SESSION["translate"]->it("Abbreviation"); return PHPWS_Template::processTemplate($tags, "ffl", "edit_position.tpl"); }// END FUNC _edit function _save() { if (!$_SESSION["OBJ_user"]->allow_access("ffl", "edit_positions")) { $message = $_SESSION["translate"]->it("Access to save positions was denied due to lack of proper permissions."); $error = new PHPWS_Error("ffl", "FFL_Position::_save()", $message, "exit", 1); $error->message(); return FALSE; } $content = null; if (isset($_REQUEST["Position_fullname"])) $this->setLabel($_REQUEST["Position_fullname"]); if (isset($_REQUEST["Position_abbrname"])) $this->_abbrname = $_REQUEST["Position_abbrname"]; $error = $this->commit(); if (PHPWS_Error::isError($error)) { $message = $_SESSION["translate"]->it("The position could not be saved to the database."); $error = new PHPWS_Error("ffl", $message, "continue", 0); $error->message("CNT_ffl"); $_REQUEST["FFL_POSITION_OP"] = "edit"; $this->action(); return; } else { $content .= $_SESSION["translate"]->it("The position was successfully saved.") . "<br />\n"; } return $content; }// END FUNC _save function _delete() { if (!$_SESSION["OBJ_user"]->allow_access("ffl", "delete_positions")) { $message = $_SESSION["translate"]->it("Access to delete position was denied due to lack of proper permissions."); $error = new PHPWS_Error("ffl", "FFL_Position::_delete()", $message, "exit", 1); $error->message(); return FALSE; } $content = null; if (isset($_REQUEST["Position_yes"])) { $this->kill(); $content .= $_SESSION["translate"]->it("The position [var1] was successfully deleted from the database.", "<b><i>" . $this->getLabel() . "</i></b>"); } elseif (isset($_REQUEST["Position_no"])) { $content .= $_SESSION["translate"]->it("No position was deleted from the database."); } else { $form = new EZform("FFL_Position_delete"); $form->add("module", "hidden", "ffl"); $form->add("FFL_POSITION_OP", "hidden", "delete"); $form->add("Position_yes", "submit", $_SESSION["translate"]->it("Yes")); $form->add("Position_no", "submit", $_SESSION["translate"]->it("No")); $tags = array(); $tags = $form->getTemplate(); $tags["MESSAGE"] = $_SESSION["translate"]->it("Are you sure you want to delete this position?"); $content .= PHPWS_Template::processTemplate($tags, "ffl", "delete_position.tpl"); } return $content; }// END FUNC _delete function action() { switch($_REQUEST["FFL_POSITION_OP"]) { case "edit": if (isset($this->_id)) $title = $_SESSION["translate"]->it("Edit Position"); else $title = $_SESSION["translate"]->it("New Position"); $content = $_SESSION["FFL_Manager"]->_menu() . $this->_edit(); break; case "save": $title = $_SESSION["translate"]->it("Save Position"); $content = $_SESSION["FFL_Manager"]->_menu() . $this->_save(); break; case "delete": $title = $_SESSION["translate"]->it("Delete Position"); $content = $_SESSION["FFL_Manager"]->_menu() . $this->_delete(); break; default: $title = "NO OP"; $content = "This function is not yet implemented."; } if (isset($content)) { $GLOBALS["CNT_ffl"]["title"] = $title; $GLOBALS["CNT_ffl"]["content"] .= $content; } }// END FUNC action }// END CLASS FFL_Position ?> |