public function CreatePage() { parent::CreatePage(); // Doesnt necessary get PX, because PX is protected! $users = $this->getUsersDatabase(); //anydataset.SingleRow user; $action = strtolower($this->_action); $uid = $this->_context->get("valueid"); $this->myWords = $this->WordCollection(); $this->setTitlePage($this->myWords->Value("TITLE")); $this->setHelp($this->myWords->Value("DESCRIPTION")); $this->addMenuOption($this->myWords->Value("NEWUSER"), $this->url, null); $this->addMenuOption($this->myWords->Value("ADDROLE"), "module:Xmlnuke.Admin.manageusersgroups", null); // -------------------------------------- // CHECK ACTION // -------------------------------------- $exec = false; if ($action != "" && $action != "move") { $message = new XmlParagraphCollection(); if ($action == "newuser") { if (!$users->addUser($this->_context->get("name"), $this->_context->get("login"), $this->_context->get("email"), $this->_context->get("password"))) { $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("USEREXIST"), true)); } else { if ($this->isUserAdmin()) { $user = $users->getUserName($this->_context->get("login")); $user->setField($users->getUserTable()->admin, $this->_context->get("admin")); $users->Save(); } $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("CREATED"), true)); } $exec = true; } if ($action == "update") { $user = $users->getById($uid); $user->setField($users->getUserTable()->name, $this->_context->get("name")); $user->setField($users->getUserTable()->email, $this->_context->get("email")); if ($this->isUserAdmin()) { $user->setField($users->getUserTable()->admin, $this->_context->get("admin")); } $users->Save(); $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("UPDATE"), true)); $exec = true; } if ($action == "changepassword") { $user = $users->getById($uid); $user->setField($users->getUserTable()->password, $users->getSHAPassword($this->_context->get("password"))); $users->Save(); $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("CHANGEPASSWORD"), true)); $exec = true; } if ($action == "delete") { if ($users->removeUserName($uid)) { $users->Save(); $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("DELETE"), true)); $uid = ""; } else { $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("ERRO"), true)); } $exec = true; } if ($action == "addrole") { $users->addPropertyValueToUser($uid, $this->_context->get("role"), UserProperty::Role); $users->Save(); $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("ROLEADDED"), true)); $exec = true; } if ($action == "removerole") { $users->removePropertyValueFromUser($uid, $this->_context->get("role"), UserProperty::Role); $users->Save(); $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("ROLEREMOVED"), true)); $exec = true; } if ($action == "addcustomvalue") { $users->addPropertyValueToUser($uid, $this->_context->get("customvalue"), $this->_context->get("customfield")); $users->Save(); $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("CUSTOMFIELDUPDATED"), true)); $exec = true; } if ($action == "removecustomvalue") { $users->removePropertyValueFromUser($uid, $this->_context->get("customvalue"), $this->_context->get("customfield")); $users->Save(); $message->addXmlnukeObject(new XmlnukeText($this->myWords->Value("CUSTOMFIELDREMOVED"), true)); $exec = true; } if ($exec) { $block = new XmlBlockCollection($this->myWords->Value("WORKINGAREA"), BlockPosition::Center); $block->addXmlnukeObject($message); $this->defaultXmlnukeDocument->addXmlnukeObject($block); } } // -------------------------------------- // LIST USERS // -------------------------------------- $block = new XmlBlockCollection($this->myWords->Value("USERS"), BlockPosition::Center); $itf = new IteratorFilter(); if (!$this->isUserAdmin()) { $itf->addRelation("admin", Relation::NOT_EQUAL, "yes"); } if ($this->_context->get("pesquser") != "") { $itf->startGroup(); $itf->addRelationOr($users->getUserTable()->username, Relation::CONTAINS, $this->_context->get("pesquser")); $itf->addRelationOr($users->getUserTable()->name, Relation::CONTAINS, $this->_context->get("pesquser")); $itf->addRelationOr($users->getUserTable()->email, Relation::CONTAINS, $this->_context->get("pesquser")); $itf->endGroup(); } $it = $users->getIterator($itf); $formpesq = new XmlFormCollection($this->_context, $this->url, $this->myWords->Value("TITLEPESQUSER")); $formpesq->setFormName("form-label-top"); $textbox = new XmlInputTextBox($this->myWords->Value("PESQUSER"), "pesquser", $this->_context->get("pesquser")); $textbox->setDataType(INPUTTYPE::TEXT); $formpesq->addXmlnukeObject($textbox); $textbox->setRequired(true); $boxButton = new XmlInputButtons(); $boxButton->addSubmit($this->myWords->Value("GOSEARCH"), ""); $formpesq->addXmlnukeObject($boxButton); $block->addXmlnukeObject($formpesq); $editlist = new XmlEditList($this->_context, $this->myWords->Value("USERS"), $this->url, true, false, true, true); $editlist->setDataSource($it); $editlist->setPageSize(20, 0); $editlist->setEnablePage(true); $field = new EditListField(); $field->fieldData = $users->getUserTable()->id; $editlist->addEditListField($field); $field = new EditListField(); $field->fieldData = $users->getUserTable()->username; $field->editlistName = $this->myWords->Value("TXT_LOGIN"); $editlist->addEditListField($field); $field = new EditListField(); $field->fieldData = $users->getUserTable()->name; $field->editlistName = $this->myWords->Value("TXT_NAME"); $editlist->addEditListField($field); $field = new EditListField(); $field->fieldData = $users->getUserTable()->email; $field->editlistName = $this->myWords->Value("TXT_EMAIL"); $editlist->addEditListField($field); $field = new EditListField(); $field->fieldData = $users->getUserTable()->admin; $field->editlistName = $this->myWords->Value("TITADM"); $editlist->addEditListField($field); $block->addXmlnukeObject($editlist); $this->defaultXmlnukeDocument->addXmlnukeObject($block); // -------------------------------------- // EDIT AREA // -------------------------------------- if ($action == "new" || $action == "newuser" || $action == "" || $action == "move" || $action == "delete") { $this->NewUser(); } else { $this->EditUser($users, $uid); } return $this->defaultXmlnukeDocument->generatePage(); }
public function CreatePage() { parent::CreatePage(); $myWords = $this->WordCollection(); $this->setHelp($myWords->Value("DESCRIPTION")); //this.addMenuOption("OK", "module:Xmlnuke.Admin.ManageGroup?action=aqui"); $this->setTitlePage($myWords->Value("TITLE")); //this.addMenuOption("Click here to ERASE ALL cache.", "module:Xmlnuke.Admin.CustomConfig?action=erase"); //this.addMenuOption("Click here to LIST cache.", "module:Xmlnuke.Admin.CustomConfig?action=list"); $action = strtolower($this->_action); $block = new XmlBlockCollection($myWords->Value("WORKINGAREA"), BlockPosition::Center); /* XmlNode paragraph; XmlNode form; XmlNode boxButton; */ if ($action == "update") { $nv = array(); $nv["xmlnuke.SMTPSERVER"] = $this->_context->get("smtpserver"); $nv["xmlnuke.LANGUAGESAVAILABLE"] = $this->createLanguageString(); $nv["xmlnuke.SHOWCOMPLETEERRORMESSAGES"] = $this->_context->get("showcompleterrormessages"); $nv["xmlnuke.LOGINMODULE"] = $this->_context->get("loginmodule"); $nv["xmlnuke.USERSDATABASE"] = $this->_context->get("usersdatabase"); $nv["xmlnuke.USERSCLASS"] = $this->_context->get("usersclass"); $nv["xmlnuke.DEBUG"] = $this->_context->get("txtdebug"); $nv["xmlnuke.DETECTMOBILE"] = $this->_context->get("txtdetectmobile"); $nv["xmlnuke.CAPTCHACHALLENGE"] = $this->_context->get("captchachallenge"); $nv["xmlnuke.CAPTCHALETTERS"] = $this->_context->get("captchaletters"); $nv["xmlnuke.ENABLEPARAMPROCESSOR"] = $this->_context->get("enableparamprocessor"); $nv["xmlnuke.USEFULLPARAMETER"] = $this->_context->get("usefullparameter"); $nv["xmlnuke.PHPLIBDIR"] = $this->_context->get("phplibdir"); # PHP SPECIFIC $this->_context->updateCustomConfig($nv); $paragraph = new XmlParagraphCollection(); $paragraph->addXmlnukeObject(new XmlnukeText($myWords->Value("UPDATED"), true)); $block->addXmlnukeObject($paragraph); } $form = new XmlFormCollection($this->_context, "module:Xmlnuke.Admin.CustomConfig", $myWords->Value("FORMTITLE")); $form->setJSValidate(true); $form->setFormName("form"); $truefalse = array("" => "Use Default", "true" => "True", "false" => "False"); $form->addXmlnukeObject(new XmlInputHidden("action", "update")); $form->addXmlnukeObject(new XmlInputLabelField("xmlnuke.ROOTDIR", $this->_context->get("xmlnuke.ROOTDIR"))); $form->addXmlnukeObject(new XmlInputLabelField("xmlnuke.USEABSOLUTEPATHSROOTDIR", $this->_context->get("xmlnuke.USEABSOLUTEPATHSROOTDIR"))); $form->addXmlnukeObject(new XmlInputLabelField("xmlnuke.URLMODULE", $this->_context->get("xmlnuke.URLMODULE"))); $form->addXmlnukeObject(new XmlInputLabelField("xmlnuke.URLXMLNUKEADMIN", $this->_context->get("xmlnuke.URLXMLNUKEADMIN"))); $form->addXmlnukeObject(new XmlInputLabelField("xmlnuke.URLXMLNUKEENGINE", $this->_context->get("xmlnuke.URLXMLNUKEENGINE"))); $form->addXmlnukeObject(new XmlInputLabelField("xmlnuke.DEFAULTPAGE", $this->_context->get("xmlnuke.DEFAULTPAGE"))); $form->addXmlnukeObject(new XmlInputLabelField("xmlnuke.XSLCACHE", $this->_context->get("xmlnuke.XSLCACHE"))); $form->addXmlnukeObject(new XmlInputTextBox("xmlnuke.SMTPSERVER", "smtpserver", $this->_context->get("xmlnuke.SMTPSERVER"), 30)); $this->generateLanguageInput($form); $form->addXmlnukeObject(new XmlEasyList(EasyListType::SELECTLIST, "showcompleterrormessages", "xmlnuke.SHOWCOMPLETEERRORMESSAGES", $truefalse, $this->getStringBool($this->_context->get("xmlnuke.SHOWCOMPLETEERRORMESSAGES")))); $form->addXmlnukeObject(new XmlInputTextBox("xmlnuke.LOGINMODULE", "loginmodule", $this->_context->get("xmlnuke.LOGINMODULE"), 30)); $form->addXmlnukeObject(new XmlEasyList(EasyListType::SELECTLIST, "usersdatabase", "xmlnuke.USERSDATABASE", $this->getStringConnectionsArray(), $this->_context->get("xmlnuke.USERSDATABASE"))); $form->addXmlnukeObject(new XmlInputTextBox("xmlnuke.USERSCLASS", "usersclass", $this->_context->get("xmlnuke.USERSCLASS"), 30)); $form->addXmlnukeObject(new XmlEasyList(EasyListType::SELECTLIST, "txtdetectmobile", "xmlnuke.DETECTMOBILE", $truefalse, $this->getStringBool($this->_context->get("xmlnuke.DETECTMOBILE")))); $form->addXmlnukeObject(new XmlEasyList(EasyListType::SELECTLIST, "txtdebug", "xmlnuke.DEBUG", $truefalse, $this->getStringBool($this->_context->get("xmlnuke.DEBUG")))); $form->addXmlnukeObject(new XmlEasyList(EasyListType::SELECTLIST, "captchachallenge", "xmlnuke.CAPTCHACHALLENGE", array("easy" => "Easy", "hard" => "Hard"), $this->_context->get("xmlnuke.CAPTCHACHALLENGE"))); $form->addXmlnukeObject(new XmlEasyList(EasyListType::SELECTLIST, "captchaletters", "xmlnuke.CAPTCHALETTERS", array("5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10"), $this->_context->get("xmlnuke.CAPTCHALETTERS"))); $form->addXmlnukeObject(new XmlEasyList(EasyListType::SELECTLIST, "enableparamprocessor", "xmlnuke.ENABLEPARAMPROCESSOR", $truefalse, $this->getStringBool($this->_context->get("xmlnuke.ENABLEPARAMPROCESSOR")))); $form->addXmlnukeObject(new XmlEasyList(EasyListType::SELECTLIST, "usefullparameter", "xmlnuke.USEFULLPARAMETER", $truefalse, $this->getStringBool($this->_context->get("xmlnuke.USEFULLPARAMETER")))); $form->addXmlnukeObject(new XmlInputLabelField("xmlnuke.CACHESTORAGEMETHOD", $this->_context->get("xmlnuke.CACHESTORAGEMETHOD"))); $form->addXmlnukeObject(new XmlInputLabelField("xmlnuke.XMLSTORAGEMETHOD", $this->_context->get("xmlnuke.XMLSTORAGEMETHOD"))); $form->addXmlnukeObject(new XmlInputLabelField("xmlnuke.XMLNUKEDATA", $this->_context->get("xmlnuke.XMLNUKEDATA"))); $form->addXmlnukeObject(new XmlInputTextBox("xmlnuke.PHPLIBDIR", "phplibdir", $this->_context->get("xmlnuke.PHPLIBDIR"), 30)); $boxButton = new XmlInputButtons(); $boxButton->addSubmit($myWords->Value("TXT_SAVE")); $form->addXmlnukeObject($boxButton); $block->addXmlnukeObject($form); $this->defaultXmlnukeDocument->addXmlnukeObject($block); return $this->defaultXmlnukeDocument; }