예제 #1
0
 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();
 }
예제 #2
0
 public function CreatePage()
 {
     parent::CreatePage();
     // Doesnt necessary get PX, because PX is protected!
     $this->myWords = $this->WordCollection();
     $this->setTitlePage($this->myWords->Value("TITLE"));
     $this->setHelp($this->myWords->Value("DESCRIPTION"));
     $this->addMenuOption($this->myWords->Value("NEWLANGUAGEFILE"), "module:Xmlnuke.Admin.EditLanguage?action=new");
     $this->addMenuOption($this->myWords->Value("VIEWSHAREDFILES"), "module:Xmlnuke.Admin.EditLanguage?op=1");
     $this->addMenuOption($this->myWords->Value("VIEWPRIVATEFILES"), "module:Xmlnuke.Admin.EditLanguage");
     $block = new XmlBlockCollection($this->myWords->Value("WORKINGAREA"), BlockPosition::Center);
     $this->defaultXmlnukeDocument->addXmlnukeObject($block);
     $op = $this->_context->get("op");
     $ed = $this->_context->get("ed");
     $langDir = new AnydatasetLangFilenameProcessor("");
     if ($op == "") {
         $filelist = FileUtil::RetrieveFilesFromFolder($langDir->PrivatePath(), $langDir->Extension());
     } else {
         $filelist = FileUtil::RetrieveFilesFromFolder($langDir->SharedPath(), $langDir->Extension());
     }
     $it = $this->getIteratorFromList($filelist, $langDir);
     if ($this->_action == "") {
         $editlist = new XmlEditList($this->_context, $this->myWords->Value("FILELIST{$op}"), "module:Xmlnuke.Admin.EditLanguage", true, false, true, false);
         $field = new EditListField();
         $field->editlistName = "#";
         $field->fieldData = "key";
         $editlist->addEditListField($field);
         $field = new EditListField();
         $field->editlistName = "Language Filename";
         $field->fieldData = "singlename";
         $editlist->addEditListField($field);
         $editlist->setDataSource($it);
         $editlist->addParameter("op", $op);
         $editlist->setEnablePage(true);
         $editlist->setPageSize(20, 0);
         $block->addXmlnukeObject($editlist);
     } elseif ($this->_action == ModuleAction::Edit || $ed == 1) {
         if ($ed == 1) {
             $file = $this->_context->get("file");
         } else {
             $file = $this->_context->get("valueid");
         }
         $langDir = new AnydatasetLangFilenameProcessor($file);
         $langDir->setFilenameLocation($op == "" ? ForceFilenameLocation::PrivatePath : ForceFilenameLocation::SharedPath);
         $anydata = new AnyDataset($langDir->FullQualifiedNameAndPath());
         $it = $anydata->getIterator();
         $sr = $it->moveNext();
         $arFields = $sr->getFieldNames();
         $i = 0;
         $CrudFieldCollection = new CrudFieldCollection();
         foreach ($arFields as $value) {
             $process = CrudField::FactoryMinimal($value, $value, 40, $i < 4, true);
             $process->key = $i == 0;
             if ($value == "LANGUAGE") {
                 $process->beforeInsertFormatter = $this;
             }
             $CrudFieldCollection->addCrudField($process);
             $i++;
         }
         $crud = new XmlnukeCrudAnydata($this->_context, $CrudFieldCollection, $this->myWords->Value("EDITLANGUAGE", $file), "module:Xmlnuke.Admin.EditLanguage", null, $langDir);
         $crud->addParameter("op", $op);
         $crud->addParameter("ed", 1);
         $crud->addParameter("file", $file);
         $block->addXmlnukeObject($crud);
     } elseif ($this->_action == ModuleAction::Create) {
         $form = new XmlFormCollection($this->_context, "module:Xmlnuke.Admin.EditLanguage", $this->myWords->Value("NEWLANGUAGEFILE"));
         $form->addXmlnukeObject(new XmlInputHidden("action", ModuleAction::CreateConfirm));
         $form->addXmlnukeObject(new XmlInputHidden("op", $op));
         $form->addXmlnukeObject(new XmlInputTextBox($this->myWords->Value("NEWFILE"), "newfile", "", 30));
         $form->addXmlnukeObject(new XmlInputMemo($this->myWords->Value("FIELDS"), "fields", "TITLE\r\nABSTRACT"));
         $form->addXmlnukeObject(XmlInputButtons::CreateSubmitButton($this->myWords->Value("TXT_SUBMIT")));
         $block->addXmlnukeObject($form);
     } elseif ($this->_action == ModuleAction::CreateConfirm) {
         $file = $this->_context->get("newfile");
         $langDir = new AnydatasetLangFilenameProcessor($file);
         $langDir->setFilenameLocation($op == "" ? ForceFilenameLocation::PrivatePath : ForceFilenameLocation::SharedPath);
         $anydata = new AnyDataset($langDir->FullQualifiedNameAndPath());
         $fields = explode("\r\n", $this->_context->get("fields"));
         $langs = $this->_context->LanguagesAvailable();
         foreach ($langs as $lang => $dummy) {
             $anydata->appendRow();
             $anydata->addField("lang", $lang);
             foreach ($fields as $field) {
                 $anydata->addField($field, "");
             }
         }
         $anydata->Save($langDir);
         $this->_context->redirectUrl("module:Xmlnuke.Admin.EditLanguage?ed=1&file={$file}");
     }
     $langfile = $this->_context->get("langfile");
     $contents = $this->_context->get("contents");
     $contents = stripslashes($contents);
     return $this->defaultXmlnukeDocument;
 }
예제 #3
0
 /**
  *@desc
  *@param
  *@return IXmlnukeDocumentObject
  */
 protected function listAllRecords()
 {
     //		XmlEditList $editList
     $editList = new XmlEditList($this->_context, $this->_header, $this->_module, false, false, false, false);
     $editList->setDataSource($this->getAllRecords());
     $editList->setPageSize($this->_qtdRows, $this->_curPage);
     $editList->setEnablePage(true);
     //$editList->addParameter("filter", $this->_filter);
     //$editList->addParameter("sort", $this->_sort);
     foreach ($this->_parameter as $key => $value) {
         $editList->addParameter($key, $value);
     }
     if ($this->_new) {
         $cb = new CustomButtons();
         $cb->action = self::ACTION_NEW;
         $cb->alternateText = $this->_lang->Value("TXT_NEW");
         $cb->icon = "common/editlist/ic_novo.gif";
         $cb->enabled = true;
         $cb->multiple = MultipleSelectType::NONE;
         $editList->setCustomButton($cb);
     }
     if ($this->_view) {
         $cb = new CustomButtons();
         $cb->action = self::ACTION_VIEW;
         $cb->alternateText = $this->_lang->Value("TXT_VIEW");
         $cb->icon = "common/editlist/ic_detalhes.gif";
         $cb->enabled = true;
         $cb->multiple = MultipleSelectType::ONLYONE;
         $editList->setCustomButton($cb);
     }
     if ($this->_edit) {
         $cb = new CustomButtons();
         $cb->action = self::ACTION_EDIT;
         $cb->alternateText = $this->_lang->Value("TXT_EDIT");
         $cb->icon = "common/editlist/ic_editar.gif";
         $cb->enabled = true;
         $cb->multiple = MultipleSelectType::ONLYONE;
         $editList->setCustomButton($cb);
     }
     if ($this->_delete) {
         $cb = new CustomButtons();
         $cb->action = self::ACTION_DELETE;
         $cb->alternateText = $this->_lang->Value("TXT_DELETE");
         $cb->icon = "common/editlist/ic_excluir.gif";
         $cb->enabled = true;
         $cb->multiple = MultipleSelectType::ONLYONE;
         $editList->setCustomButton($cb);
     }
     if ($this->_buttons != null) {
         for ($i = 0, $buttonsLength = sizeof($this->_buttons); $i < $buttonsLength; $i++) {
             //				CustomButtons $cb;
             if ($this->_buttons[$i]->action != "" || $this->_buttons[$i]->url != "") {
                 $cb = new CustomButtons();
                 $cb->action = $this->_buttons[$i]->action;
                 $cb->alternateText = $this->_buttons[$i]->alternateText;
                 $cb->icon = $this->_buttons[$i]->icon;
                 $cb->url = $this->_buttons[$i]->url;
                 $cb->enabled = true;
                 $cb->multiple = $this->_buttons[$i]->multiple;
                 $editList->setCustomButton($cb);
             }
         }
     }
     $fldKey = "";
     for ($i = 0, $current = 0; $i < sizeof($this->_keyIndex); $i++, $current++) {
         $fldKey .= ($fldKey != "" ? "|" : "") . $this->_fields[$this->_keyIndex[$i]]->fieldName;
     }
     $field = new EditListField();
     $field->fieldData = $fldKey;
     $field->editlistName = "#";
     $field->formatter = new CrudPKFormatter();
     $field->fieldType = EditListFieldType::FORMATTER;
     $editList->addEditListField($field);
     for ($i = 0, $fieldLength = sizeof($this->_fields); $i < $fieldLength; $i++, $current++) {
         if ($this->_fields[$i]->visibleInList) {
             $field = new EditListField();
             $field->fieldData = $this->_fields[$i]->fieldName;
             $field->editlistName = $this->_fields[$i]->fieldCaption;
             if ($this->_fields[$i]->fieldXmlInput == XmlInputObjectType::SELECTLIST) {
                 $field->fieldType = EditListFieldType::LOOKUP;
                 $field->arrayLookup = $this->_fields[$i]->arraySelectList;
             } elseif ($this->_fields[$i]->fieldXmlInput == XmlInputObjectType::DUALLIST) {
                 $field->fieldType = EditListFieldType::FORMATTER;
                 $field->formatter = new CrudDualListFormatter($this->_fields[$i]->arraySelectList);
             } else {
                 $field->fieldType = EditListFieldType::TEXT;
             }
             $field->newColumn = $this->_fields[$i]->newColumn;
             if (!is_null($this->_fields[$i]->viewFormatter)) {
                 $field->formatter = $this->_fields[$i]->viewFormatter;
                 $field->fieldType = EditListFieldType::FORMATTER;
             }
             $field = $this->editListFieldCustomize($field, $this->_fields[$i]);
             $editList->addEditListField($field);
         }
     }
     return $editList;
 }
예제 #4
0
파일: Sample.php 프로젝트: byjg/xmlnuke
 /**
  * EditList
  *
  */
 protected function actionEditList()
 {
     $blockCenter = new XmlBlockCollection($this->_myWords->Value("EDITLIST"), BlockPosition::Center);
     $breakLine = new XmlnukeBreakLine();
     $firstParagraph = new XmlParagraphCollection();
     $firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("DESCEDITLISTTEXT")));
     $firstParagraph->addXmlnukeObject(new XmlnukeText($this->_myWords->Value("DESCEDITLISTTEXT2"), true, false, false));
     $firstParagraph->addXmlnukeObject($breakLine);
     $guestbookFile = new AnydatasetFilenameProcessor("guestbook");
     $guestbook = new AnyDataset($guestbookFile->FullQualifiedNameAndPath());
     $iterator = $guestbook->getIterator();
     $thirdParagraph = new XmlParagraphCollection();
     $editList = new XmlEditList($this->_context, $this->_myWords->Value("CONTENTBOOK"), $this->_url);
     $editList->setDataSource($iterator);
     $editList->addParameter("op", "3");
     $field = new EditListField();
     $field->fieldData = "frommail";
     $editList->addEditListField($field);
     $field = new EditListField();
     $field->fieldData = "fromname";
     $field->editlistName = $this->_myWords->Value("TXT_NAME");
     $editList->addEditListField($field);
     $field = new EditListField();
     $field->fieldData = "frommail";
     $field->editlistName = $this->_myWords->Value("TXT_EMAIL");
     $editList->addEditListField($field);
     $field = new EditListField();
     $field->fieldData = "message";
     $field->editlistName = $this->_myWords->Value("MESSAGE");
     $editList->addEditListField($field);
     $customButton = new CustomButtons();
     $customButton->action = "acaocustomizada";
     $customButton->enabled = true;
     $customButton->alternateText = "Texto alternativo da ação";
     $url = new XmlnukeManageUrl(URLTYPE::MODULE, "Xmlnuke.Sample");
     $url->addParam("op", 3);
     $customButton->url = $url->getUrlFull();
     $customButton->icon = "common/editlist/ic_custom.gif";
     $editList->setCustomButton($customButton);
     $editList->setPageSize(3, 0);
     $editList->setEnablePage(true);
     $thirdParagraph->addXmlnukeObject($editList);
     $secondParagraph = new XmlParagraphCollection();
     $secondParagraph->addXmlnukeObject(new XmlnukeText("Ação selecionada: ", true, false, false));
     $secondParagraph->addXmlnukeObject(new XmlnukeText($this->_action));
     $secondParagraph->addXmlnukeObject($breakLine);
     $secondParagraph->addXmlnukeObject(new XmlnukeText("Valor selecionado: ", true, false, false));
     $secondParagraph->addXmlnukeObject(new XmlnukeText($this->_context->get("valueid")));
     $blockCenter->addXmlnukeObject($firstParagraph);
     $blockCenter->addXmlnukeObject($thirdParagraph);
     if ($this->_action != "") {
         $blockCenter->addXmlnukeObject($secondParagraph);
     }
     $this->_document->addXmlnukeObject($blockCenter);
 }