Esempio n. 1
0
 /**
  * Add Group
  *
  * @author  John.meng (цот╤РШ)
  * @since   version 1.0 - 2005-12-14 22:27:14
  * @param   string  
  *
  */
 function opAdd()
 {
     global $__Lang__, $UrlParameter, $SiteDB, $AddIPObj, $FlushPHPObj, $form, $smarty;
     parent::opAdd();
     if ($_REQUEST['Action'] == 'Update') {
         $this->opUpdate();
     }
     $form->addElement('header', null, $__Lang__['langGroupAddHeader']);
     $form->addElement('text', 'GroupName', $__Lang__['langUserGroup'] . $__Lang__['langGeneralName'] . ' : ');
     $form->addElement('text', 'Descrition', $__Lang__['langUserGroup'] . $__Lang__['langGeneralDescrition'] . ' : ');
     $form->addElement('hidden', 'Module', $_REQUEST['Module']);
     $form->addElement('hidden', 'Page', $_REQUEST['Page']);
     $form->addElement('hidden', 'Action', $_REQUEST['Action']);
     $form->addElement('submit', null, $__Lang__['langGeneralSubmit']);
     $form->addRule('GroupName', $__Lang__['langGeneralPleaseEnter'] . " " . $__Lang__['langUserGroup'] . $__Lang__['langGeneralName'], 'required');
     if ($form->validate()) {
         $record["GroupName"] = $form->exportValue('GroupName');
         $record["Descrition"] = $form->exportValue('Descrition');
         $record["AddIP"] = $AddIPObj->getTrueIP();
         $record["CreateTime"] = time();
         $dbAppObj = $FlushPHPObj->loadApp("DBApp");
         if ($_POST['ID'] && $_POST['Action'] == 'Update') {
             $thisDAO =& new GroupDAO();
             $thisDAO->opUpdate(GROUPS_TABLE, $record, " GroupsID = " . $_POST['ID']);
             $form->setElementError('GroupName', $__Lang__['langGeneralOperation'] . $__Lang__['langGeneralSuccess']);
             $form->freeze();
         } else {
             if ($dbAppObj->checkExists(GROUPS_TABLE, " GroupName='" . $record["GroupName"] . "' ")) {
                 $form->setElementError('GroupName', $__Lang__['langUserNameExist']);
             } else {
                 $thisDAO = new GroupDAO();
                 $thisDAO->opAdd(GROUPS_TABLE, $record);
                 $form->setElementError('GroupName', $__Lang__['langGeneralOperation'] . $__Lang__['langGeneralSuccess']);
                 $form->freeze();
             }
         }
     }
     $smarty->assign("Main", $form->toHTML());
 }