From dfbbd0ed21e4bcd9901ad141e45649ac5799cbbc Mon Sep 17 00:00:00 2001 From: ggoffy Date: Tue, 19 May 2020 17:00:47 +0200 Subject: [PATCH] - added notification event new, modify, approve - added yoda condition - editor admin/user --- _TODO.txt | 2 +- _archive/class/Files/User/UserBroken.php | 2 +- _archive/class/Files/User/UserSubmit.php | 2 +- class/Files/Admin/AdminBroken.php | 5 +- class/Files/Admin/AdminPermissions.php | 2 +- class/Files/Classes/ClassFiles.php | 40 ++-- class/Files/Classes/ClassFormElements.php | 12 +- class/Files/Classes/ClassSpecialFiles.php | 2 +- class/Files/CreateHtmlCode.php | 5 +- class/Files/CreatePhpCode.php | 13 +- class/Files/CreateSmartyCode.php | 4 +- class/Files/CreateXoopsCode.php | 68 ++++-- class/Files/Language/LanguageAdmin.php | 10 +- class/Files/Language/LanguageMailTpl.php | 23 +- class/Files/Language/LanguageModinfo.php | 9 +- .../Templates/Admin/TemplatesAdminBroken.php | 18 +- .../Templates/User/Defstyle/Breadcrumbs.php | 3 +- .../Templates/User/Defstyle/Categories.php | 3 +- .../User/Defstyle/CategoriesList.php | 3 +- .../Files/Templates/User/Defstyle/Footer.php | 3 +- class/Files/Templates/User/Defstyle/Pages.php | 10 +- .../Templates/User/Defstyle/PagesItem.php | 4 +- .../Templates/User/Defstyle/PagesList.php | 6 +- class/Files/User/UserPages.php | 204 +++++++++++------- class/Files/User/UserRate.php | 4 +- class/Files/User/UserXoopsVersion.php | 47 ++-- class/Files/admin/AdminPages.php | 50 ++--- class/Files/admin/AdminXoopsCode.php | 3 +- docs/changelog.txt | 3 + 29 files changed, 334 insertions(+), 226 deletions(-) diff --git a/_TODO.txt b/_TODO.txt index 87c476c0..c051aea7 100644 --- a/_TODO.txt +++ b/_TODO.txt @@ -9,7 +9,7 @@ I moved files, where I do not know whether they are still needed into folder _ar TODOs: -implement constants interface +new xoops_confirm Broken files: diff --git a/_archive/class/Files/User/UserBroken.php b/_archive/class/Files/User/UserBroken.php index e3e57a62..253a27d2 100644 --- a/_archive/class/Files/User/UserBroken.php +++ b/_archive/class/Files/User/UserBroken.php @@ -85,7 +85,7 @@ public function getUserBrokenHeader($moduleDirname, $fields) $ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', ''); $ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']); $ret .= $this->getInclude(); - $ret .= $xc->getXcXoopsRequest('op', 'op', 'list'); + $ret .= $xc->getXcXoopsRequest('op', 'op', 'list', 'Cmd'); $ret .= $xc->getXcXoopsRequest($ccFieldId, $fieldId, '', 'Int'); $ret .= $pc->getPhpCodeCommentLine('Template'); $ret .= $uxc->getUserTplMain($moduleDirname, 'broken'); diff --git a/_archive/class/Files/User/UserSubmit.php b/_archive/class/Files/User/UserSubmit.php index 4603f5bf..54ec2908 100644 --- a/_archive/class/Files/User/UserSubmit.php +++ b/_archive/class/Files/User/UserSubmit.php @@ -87,7 +87,7 @@ public function getUserSubmitHeader($moduleDirname, $tablePermissions) $ret .= $this->getInclude(); $ret .= $xc->getXcXoopsLoadLanguage('admin', '', $moduleDirname); $ret .= $pc->getPhpCodeCommentLine('It recovered the value of argument op in URL$'); - $ret .= $xc->getXcXoopsRequest('op', 'op', 'form'); + $ret .= $xc->getXcXoopsRequest('op', 'op', 'form', 'Cmd'); $ret .= $pc->getPhpCodeCommentLine('Template'); $ret .= $uxc->getUserTplMain($moduleDirname, 'submit'); $ret .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'header', true); diff --git a/class/Files/Admin/AdminBroken.php b/class/Files/Admin/AdminBroken.php index ad3a1735..eee9f8be 100644 --- a/class/Files/Admin/AdminBroken.php +++ b/class/Files/Admin/AdminBroken.php @@ -72,7 +72,8 @@ public function write($module, $tables, $filename) /** * @private function getAdminBrokenHeader * @param $moduleDirname - * @param $fieldId + * @param $tableName + * @param string $t * @return string */ private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '') @@ -96,7 +97,7 @@ private function getAdminBrokenHeader($moduleDirname, $tableName, $t = '') /** * @private function getAdminBrokenList - * @param $table + * @param $tables * @param $language * @param string $t * @return string diff --git a/class/Files/Admin/AdminPermissions.php b/class/Files/Admin/AdminPermissions.php index 26db35a4..586efc0d 100644 --- a/class/Files/Admin/AdminPermissions.php +++ b/class/Files/Admin/AdminPermissions.php @@ -106,7 +106,7 @@ private function getPermissionsHeader($module, $language) $ret .= $axc->getAdminTemplateMain($moduleDirname, 'permissions'); $ret .= $xc->getXcXoopsTplAssign('navigation', "\$adminObject->displayNavigation('permissions.php')"); $ret .= $pc->getPhpCodeBlankLine(); - $ret .= $xc->getXcXoopsRequest('op', 'op', 'global'); + $ret .= $xc->getXcXoopsRequest('op', 'op', 'global', 'Cmd'); $ret .= $pc->getPhpCodeBlankLine(); $ret .= $pc->getPhpCodeCommentLine('Get Form'); $ret .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/xoopsform/grouppermform', true); diff --git a/class/Files/Classes/ClassFiles.php b/class/Files/Classes/ClassFiles.php index 0ff763ae..ab157a79 100644 --- a/class/Files/Classes/ClassFiles.php +++ b/class/Files/Classes/ClassFiles.php @@ -276,9 +276,10 @@ private function getFunctionForm($module, $table, $fieldId, $fieldInForm) $action = $xc->getXcEqualsOperator('$action', "\$_SERVER['REQUEST_URI']", null, "\t\t\t"); $ucfModuleDirname = ucfirst($moduleDirname); $getForm = $xc->getXcGetInstance('helper', "\XoopsModules\\{$ucfModuleDirname}\Helper", "\t\t"); - $getForm .= $pc->getPhpCodeConditions('false', ' === ', '$action', $action, false, "\t\t"); + $getForm .= $pc->getPhpCodeConditions('$action', ' === ', 'false', $action, false, "\t\t"); $xUser = $pc->getPhpCodeGlobals('xoopsUser'); $xModule = $pc->getPhpCodeGlobals('xoopsModule'); + $getForm .= $xc->getXcEqualsOperator('$isAdmin', $xUser . '->isAdmin(' . $xModule . '->mid())', null, "\t\t"); $permString = 'upload_groups'; if (1 != $tableCategory/* && (1 == $tablePermissions)*/) { $getForm .= $pc->getPhpCodeCommentLine('Permissions for', 'uploader', "\t\t"); @@ -288,7 +289,7 @@ private function getFunctionForm($module, $table, $fieldId, $fieldInForm) $ternaryOperator = $pc->getPhpCodeTernaryOperator('permissionUpload', $checkRight, 'true', 'false', "\t\t\t"); $permissionUpload = $xc->getXcEqualsOperator('$permissionUpload', 'true', null, "\t\t\t\t"); $ternOperator = $pc->getPhpCodeRemoveCarriageReturn($ternaryOperator, '', "\r"); - $if = $pc->getPhpCodeConditions('!' . $xUser . '->isAdmin(' . $xModule . '->mid())', '', '', "\t" . $ternaryOperator, $permissionUpload, "\t\t\t"); + $if = $pc->getPhpCodeConditions('$isAdmin', '', '', "\t" . $ternaryOperator, $permissionUpload, "\t\t\t"); $getForm .= $pc->getPhpCodeConditions($xUser, '', '', $if, $ternOperator, "\t\t"); } $getForm .= $pc->getPhpCodeCommentLine('Title', '', "\t\t"); @@ -390,44 +391,57 @@ private function getValuesInObject($moduleDirname, $table, $fields) $utility = 0; $header = ''; $configMaxchar = 0; + $lenMaxName = 0; + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + $rpFieldName = $this->getRightString($fieldName); + $len = strlen($rpFieldName); + if (3 == $fields[$f]->getVar('field_element') || 4 == $fields[$f]->getVar('field_element')) { + $len = $len + strlen('_short'); + } + $lenMaxName = max($len, $lenMaxName); + } foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldElement = $fields[$f]->getVar('field_element'); $rpFieldName = $this->getRightString($fieldName); + $spacer = str_repeat(' ', $lenMaxName - strlen($rpFieldName)); switch ($fieldElement) { case 3: - $getValues .= $pc->getPhpCodeStripTags("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}', 'e')", false, "\t\t"); + $getValues .= $pc->getPhpCodeStripTags("ret['{$rpFieldName}']{$spacer}", "\$this->getVar('{$fieldName}', 'e')", false, "\t\t"); if ($configMaxchar == 0) { $getValues .= $xc->getXcEqualsOperator('$editorMaxchar', $xc->getXcGetConfig('editor_maxchar'), false, "\t\t"); $configMaxchar = 1; } $truncate = "\$utility::truncateHtml(\$ret['{$rpFieldName}'], \$editorMaxchar)"; - $getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}_short']", $truncate, false, "\t\t"); + $spacer = str_repeat(' ', $lenMaxName - strlen($rpFieldName) - strlen('_short')); + $getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}_short']{$spacer}", $truncate, false, "\t\t"); $helper = 1; $utility = 1; break; case 4: - $getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']", 'this', $fieldName, false, "\t\t", ", 'e'"); + $getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']{$spacer}", 'this', $fieldName, false, "\t\t", ", 'e'"); if ($configMaxchar == 0) { $getValues .= $xc->getXcEqualsOperator('$editorMaxchar', $xc->getXcGetConfig('editor_maxchar'), false, "\t\t"); $configMaxchar = 1; } $truncate = "\$utility::truncateHtml(\$ret['{$rpFieldName}'], \$editorMaxchar)"; - $getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}_short']", $truncate, false, "\t\t"); + $spacer = str_repeat(' ', $lenMaxName - strlen($rpFieldName) - strlen('_short')); + $getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}_short']{$spacer}", $truncate, false, "\t\t"); $helper = 1; $utility = 1; break; case 6: - $getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']", "(int)\$this->getVar('{$fieldName}') > 0 ? _YES : _NO", false, "\t\t"); + $getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']{$spacer}", "(int)\$this->getVar('{$fieldName}') > 0 ? _YES : _NO", false, "\t\t"); break; case 8: - $getValues .= $xc->getXcXoopsUserUnameFromId("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}')", "\t\t"); + $getValues .= $xc->getXcXoopsUserUnameFromId("ret['{$rpFieldName}']{$spacer}", "\$this->getVar('{$fieldName}')", "\t\t"); break; case 15: - $getValues .= $xc->getXcFormatTimeStamp("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}')", 's', "\t\t"); + $getValues .= $xc->getXcFormatTimeStamp("ret['{$rpFieldName}']{$spacer}", "\$this->getVar('{$fieldName}')", 's', "\t\t"); break; case 21: - $getValues .= $xc->getXcFormatTimeStamp("ret['{$rpFieldName}']", "\$this->getVar('{$fieldName}')", 'm', "\t\t"); + $getValues .= $xc->getXcFormatTimeStamp("ret['{$rpFieldName}']{$spacer}", "\$this->getVar('{$fieldName}')", 'm', "\t\t"); break; default: $fieldElements = $tc->getHandler('Fieldelements')->get($fieldElement); @@ -448,10 +462,10 @@ private function getValuesInObject($moduleDirname, $table, $fields) $getTopicTable = "\${$topicTableName}Handler->get(\$this->getVar('{$fieldName}'))"; $getValues .= $xc->getXcEqualsOperator("\${$topicTableName}Obj", $getTopicTable, null, "\t\t"); $fMainTopic = "\${$topicTableName}Obj->getVar('{$fieldMainTopic}')"; - $getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']", $fMainTopic, null, "\t\t"); + $getValues .= $xc->getXcEqualsOperator("\$ret['{$rpFieldName}']{$spacer}", $fMainTopic, null, "\t\t"); $helper = 1; } else { - $getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']", 'this', $fieldName, false, "\t\t"); + $getValues .= $xc->getXcGetVar("ret['{$rpFieldName}']{$spacer}", 'this', $fieldName, false, "\t\t"); } break; } @@ -522,7 +536,7 @@ private function getOptionsCheck($table) $rpFieldName = $this->getRightString($fieldName); if (5 == $fieldElementId) { $arrayPush = $pc->getPhpCodeArrayType('ret', 'push', "'{$rpFieldName}'", null, false, "\t\t\t"); - $getOptions .= $pc->getPhpCodeConditions(1, ' == ', "\$this->getVar('{$fieldName}')", $arrayPush, false, "\t\t"); + $getOptions .= $pc->getPhpCodeConditions("\$this->getVar('{$fieldName}')", ' == ', '1', $arrayPush, false, "\t\t"); } } diff --git a/class/Files/Classes/ClassFormElements.php b/class/Files/Classes/ClassFormElements.php index 7718cca9..6c491d43 100644 --- a/class/Files/Classes/ClassFormElements.php +++ b/class/Files/Classes/ClassFormElements.php @@ -124,11 +124,17 @@ private function getXoopsFormDhtmlTextArea($language, $fieldName, $required = 'f $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $cxc = Modulebuilder\Files\Classes\ClassXoopsCode::getInstance(); - $rpFieldName = $tf->getRightString($fieldName); + //$rpFieldName = $tf->getRightString($fieldName); $ccFieldName = $tf->getCamelCase($fieldName, false, true); $ret = $pc->getPhpCodeCommentLine('Form Editor', 'DhtmlTextArea ' . $ccFieldName, "\t\t"); $ret .= $pc->getPhpCodeArray('editorConfigs', null, false, "\t\t"); - $getConfig = $xc->getXcGetConfig('editor_default'); + $getConfig = $xc->getXcGetConfig('editor_admin'); + $contIf = $xc->getXcEqualsOperator("\$editor", $getConfig, null, "\t\t\t"); + $getConfig = $xc->getXcGetConfig('editor_user'); + $contElse = $xc->getXcEqualsOperator("\$editor", $getConfig, null, "\t\t\t"); + $ret .= $pc->getPhpCodeConditions('$isAdmin','','', $contIf, $contElse, "\t\t"); + + $configs = [ 'name' => "'{$fieldName}'", 'value' => "\$this->getVar('{$fieldName}', 'e')", @@ -136,7 +142,7 @@ private function getXoopsFormDhtmlTextArea($language, $fieldName, $required = 'f 'cols' => 40, 'width' => "'100%'", 'height' => "'400px'", - 'editor' => $getConfig, + 'editor' => '$editor', ]; foreach ($configs as $c => $d) { $ret .= $xc->getXcEqualsOperator("\$editorConfigs['{$c}']", $d, null, "\t\t"); diff --git a/class/Files/Classes/ClassSpecialFiles.php b/class/Files/Classes/ClassSpecialFiles.php index bfedef01..b37c92ce 100644 --- a/class/Files/Classes/ClassSpecialFiles.php +++ b/class/Files/Classes/ClassSpecialFiles.php @@ -138,7 +138,7 @@ public function getGlobalPerms($permId) $contIfInt = $xc->getXcEqualsOperator('$my_group_ids', '[XOOPS_GROUP_ANONYMOUS]', null, "\t\t\t"); $contElseInt = $xc->getXcEqualsOperator('$my_group_ids', '$memberHandler->getGroupsByUser($currentuid);', null, "\t\t\t"); - $globalContent .= $pc->getPhpCodeConditions('0', ' == ', '$currentuid', $contIfInt, $contElseInt, "\t\t"); + $globalContent .= $pc->getPhpCodeConditions('$currentuid', ' == ', '0', $contIfInt, $contElseInt, "\t\t"); $globalContent .= $cond; $globalContent .= $this->getSimpleString("return false;", "\t\t"); $functions .= $pc->getPhpCodeFunction($funcname, '', $globalContent, 'public ', false, "\t"); diff --git a/class/Files/CreateHtmlCode.php b/class/Files/CreateHtmlCode.php index c23efb8e..29ac729f 100644 --- a/class/Files/CreateHtmlCode.php +++ b/class/Files/CreateHtmlCode.php @@ -111,7 +111,8 @@ public function getHtmlEmpty($empty = '', $t = '', $n = '') /** * @public function getHtmlComment * @param string $htmlComment - * @param string $n + * @param string $t + * @param string $n * @return string */ public function getHtmlComment($htmlComment = '', $t = '', $n = '') @@ -203,6 +204,7 @@ public function getHtmlPre($content = '', $preClass = '', $t = '', $n = "\n") * @param string $spanClass * @param string $t * @param string $n + * @param bool $split * @return string */ public function getHtmlSpan($content = '', $spanClass = '', $t = '', $n = "\n", $split = false) @@ -243,6 +245,7 @@ public function getHtmlParagraph($content = '', $pClass = '', $t = '', $n = "\n" * @public function getHtmlI * @param string $content * @param string $iClass + * @param string $iId * @param string $t * @param string $n * @return string diff --git a/class/Files/CreatePhpCode.php b/class/Files/CreatePhpCode.php index 0841be9b..5ef1b9a6 100644 --- a/class/Files/CreatePhpCode.php +++ b/class/Files/CreatePhpCode.php @@ -251,6 +251,7 @@ public function getPhpCodeTernaryOperator($return, $condition, $one, $two, $t = * @param $extends * @param $type * + * @param null $implements * @return string */ public function getPhpCodeClass($name = null, $content = null, $extends = null, $type = null, $implements = null) @@ -337,12 +338,20 @@ public function getPhpCodeFunction($name = null, $params = null, $content = null */ public function getPhpCodeConditions($condition = null, $operator = null, $type = null, $contentIf = null, $contentElse = false, $t = '', $conditionElse = '') { + if ('==' === trim($operator) || '===' === trim($operator) || '!=' === trim($operator) || '!==' === trim($operator)) { + //yoda conditions + $left = $type; + $right = $condition; + } else { + $left = $condition; + $right = $type; + } if (false === $contentElse) { - $ret = "{$t}if ({$condition}{$operator}{$type}) {\n"; + $ret = "{$t}if ({$left}{$operator}{$right}) {\n"; $ret .= $contentIf; $ret .= "{$t}}\n"; } else { - $ret = "{$t}if ({$condition}{$operator}{$type}) {\n"; + $ret = "{$t}if ({$left}{$operator}{$right}) {\n"; $ret .= $contentIf; if ('' !== $conditionElse) { $ret .= "{$t}} elseif ({$conditionElse}) {\n"; diff --git a/class/Files/CreateSmartyCode.php b/class/Files/CreateSmartyCode.php index 12ed00e4..f24413e7 100644 --- a/class/Files/CreateSmartyCode.php +++ b/class/Files/CreateSmartyCode.php @@ -196,7 +196,8 @@ public function getSmartyIncludeFile($moduleDirname, $fileName = 'header', $admi * @public function getSmartyIncludeFileListSection * @param $moduleDirname * @param $fileName - * @param $tableFieldName + * @param $itemName + * @param $arrayName * @param string $t * @param string $n * @return string @@ -231,6 +232,7 @@ public function getSmartyIncludeFileListForeach($moduleDirname, $fileName, $tabl * @param bool $noSimbol * @param string $t * @param string $n + * @param bool $split * @return string */ public function getSmartyConditions($condition = '', $operator = '', $type = '', $contentIf = '', $contentElse = false, $count = false, $noSimbol = false, $t = '', $n = "\n", $split = true) diff --git a/class/Files/CreateXoopsCode.php b/class/Files/CreateXoopsCode.php index bcba1275..304ec0c6 100644 --- a/class/Files/CreateXoopsCode.php +++ b/class/Files/CreateXoopsCode.php @@ -632,6 +632,8 @@ public function getXcXoopsRequest($left = '', $var1 = '', $var2 = '', $type = 'S $ret .= "{$t}\${$left} = Request::getInt({$intVars});\n"; } elseif ('Int' === $type && false !== $method) { $ret .= "{$t}\${$left} = Request::getInt({$intVars}, '{$method}');\n"; + } else { + $ret .= "{$t}\${$left} = Request::get{$type}('{$var1}', '{$var2}');\n"; } return $ret; @@ -731,6 +733,19 @@ public function getXcHandlerCreateObj($tableName, $t = '') return "{$t}\${$tableName}Obj = \${$tableName}Handler->create();\n"; } + /** + * @public function getXcHandlerGetObj + * + * @param $tableName + * @param $ccFieldId + * @param string $t + * @return string + */ + public function getXcHandlerGetObj($tableName, $ccFieldId, $t = '') + { + return "{$t}\${$tableName}Obj = \${$tableName}Handler->get(\${$ccFieldId});\n"; + } + /** * @public function getXcHandlerCountObj * @@ -1207,6 +1222,8 @@ public function getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $f * @param $tableName * * @param string $t + * @param string $paramStart + * @param string $paramOp * @return string */ public function getXcPageNav($tableName, $t = '', $paramStart = 'start', $paramOp = "'op=list&limit=' . \$limit") @@ -1738,32 +1755,49 @@ public function getXcCommonPagesNew($tableName, $t = '') * @public function getXcCommonPagesDelete * @param $language * @param $tableName + * @param $tableSoleName * @param $fieldId * @param $fieldMain + * @param $tableNotifications * @param string $t + * @param bool $admin * @return string */ - public function getXcCommonPagesDelete($language, $tableName, $fieldId, $fieldMain, $t = '') + public function getXcCommonPagesDelete($language, $tableName, $tableSoleName, $fieldId, $fieldMain, $tableNotifications, $t = '', $admin = false) { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $cf = Modulebuilder\Files\CreateFile::getInstance(); - $ccFieldId = $cf->getCamelCase($fieldId, false, true); - $ret = $xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', '', $t); - $reqOk = "_REQUEST['ok']"; - $isset = $pc->getPhpCodeIsset($reqOk); - $xoopsSecurityCheck = $xc->getXcXoopsSecurityCheck(); - $xoopsSecurityErrors = $xc->getXcXoopsSecurityErrors(); - $implode = $pc->getPhpCodeImplode(', ', $xoopsSecurityErrors); - $redirectHeaderErrors = $xc->getXcRedirectHeader($tableName, '', '3', $implode, true, $t . "\t\t"); - $delete = $xc->getXcHandlerDelete($tableName, $tableName, 'Obj', 'Handler'); - $condition = $pc->getPhpCodeConditions('!' . $xoopsSecurityCheck, '', '', $redirectHeaderErrors, false, $t . "\t"); - $redirectHeaderLanguage = $xc->getXcRedirectHeader($tableName, '', '3', "{$language}FORM_DELETE_OK", true, $t . "\t\t"); - $htmlErrors = $xc->getXcHtmlErrors($tableName, true); - $internalElse = $xc->getXcXoopsTplAssign('error', $htmlErrors, true, $t . "\t\t"); - $condition .= $pc->getPhpCodeConditions($delete, '', '', $redirectHeaderLanguage, $internalElse, $t . "\t"); - $mainElse = $xc->getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, 'delete', $t . "\t"); - $ret .= $pc->getPhpCodeConditions($isset, ' && ', "1 == \${$reqOk}", $condition, $mainElse, $t); + + $ccFieldId = $cf->getCamelCase($fieldId, false, true); + $stuFieldMain = mb_strtoupper($fieldMain); + $ccFieldMain = $cf->getCamelCase($fieldMain, false, true); + + $ret = $xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', '', $t); + $ret .= $xc->getXcGetVar($ccFieldMain, "{$tableName}Obj", $fieldMain, false, $t); + $reqOk = "_REQUEST['ok']"; + $isset = $pc->getPhpCodeIsset($reqOk); + $xoopsSecurityCheck = $xc->getXcXoopsSecurityCheck(); + $xoopsSecurityErrors = $xc->getXcXoopsSecurityErrors(); + $implode = $pc->getPhpCodeImplode(', ', $xoopsSecurityErrors); + $redirectHeaderErrors = $xc->getXcRedirectHeader($tableName, '', '3', $implode, true, $t . "\t\t"); + $delete = $xc->getXcHandlerDelete($tableName, $tableName, 'Obj', 'Handler'); + $condition = $pc->getPhpCodeConditions('!' . $xoopsSecurityCheck, '', '', $redirectHeaderErrors, false, $t . "\t"); + $contInsert = ''; + if (!$admin && 1 == $tableNotifications) { + $contInsert .= $pc->getPhpCodeCommentLine('Event delete notification', null, $t . "\t\t"); + $contInsert .= $pc->getPhpCodeArray('tags', [], false, $t . "\t\t"); + $contInsert .= $xc->getXcEqualsOperator("\$tags['{$stuFieldMain}']", "\${$ccFieldMain}", '', $t . "\t\t"); + $contInsert .= $xc->getXcXoopsHandler('notification', $t . "\t\t"); + $contInsert .= $cf->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_delete', \$tags);", $t . "\t\t"); + $contInsert .= $cf->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \${$ccFieldId}, '{$tableSoleName}_delete', \$tags);", $t . "\t\t"); + } + $contInsert .= $xc->getXcRedirectHeader($tableName, '', '3', "{$language}FORM_DELETE_OK", true, $t . "\t\t"); + $htmlErrors = $xc->getXcHtmlErrors($tableName, true); + $internalElse = $xc->getXcXoopsTplAssign('error', $htmlErrors, true, $t . "\t\t"); + $condition .= $pc->getPhpCodeConditions($delete, '', '', $contInsert, $internalElse, $t . "\t"); + $mainElse = $xc->getXcXoopsConfirm($tableName, $language, $fieldId, $fieldMain, 'delete', $t . "\t"); + $ret .= $pc->getPhpCodeConditions($isset, ' && ', "1 == \${$reqOk}", $condition, $mainElse, $t); return $ret; } diff --git a/class/Files/Language/LanguageAdmin.php b/class/Files/Language/LanguageAdmin.php index 0818c8cb..17260a48 100644 --- a/class/Files/Language/LanguageAdmin.php +++ b/class/Files/Language/LanguageAdmin.php @@ -152,7 +152,8 @@ public function getLanguageAdminPages($language, $tables) public function getLanguageAdminClass($language, $tables) { $ret = $this->defines->getAboveHeadDefines('Admin Classes'); - + $fieldStatus = 0; + $fieldSampleListValue = 0; foreach (array_keys($tables) as $t) { $tableId = $tables[$t]->getVar('table_id'); $tableMid = $tables[$t]->getVar('table_mid'); @@ -162,7 +163,6 @@ public function getLanguageAdminClass($language, $tables) $fields = $this->getTableFields($tableMid, $tableId); $fieldInForm = 0; - foreach (array_keys($fields) as $f) { if ($fieldInForm < $fields[$f]->getVar('field_inform')) { $fieldInForm = $fields[$f]->getVar('field_inform'); @@ -175,12 +175,9 @@ public function getLanguageAdminClass($language, $tables) } $ret .= $this->defines->getAboveDefines("Elements of {$ucfTableSoleName}"); - $fieldStatus = 0; - $fieldSampleListValue = 0; foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldElement = $fields[$f]->getVar('field_element'); - $rpFieldName = $this->getRightString($fieldName); if ($fieldElement > 16) { $fieldElements = Modulebuilder\Helper::getInstance()->getHandler('Fieldelements')->get($fieldElement); @@ -190,7 +187,6 @@ public function getLanguageAdminClass($language, $tables) } else { $fieldNameDesc = false !== mb_strpos($rpFieldName, '_') ? str_replace('_', ' ', ucfirst($rpFieldName)) : ucfirst($rpFieldName); } - $ret .= $this->defines->getDefine($language, $tableSoleName . '_' . $rpFieldName, $fieldNameDesc); switch ($fieldElement) { @@ -232,7 +228,6 @@ public function getLanguageAdminClass($language, $tables) $ret .= $this->defines->getDefine($language, 'FORM_ACTION', 'Action'); $ret .= $this->defines->getDefine($language, 'FORM_EDIT', 'Modification'); $ret .= $this->defines->getDefine($language, 'FORM_DELETE', 'Clear'); - if ($fieldStatus > 0) { $ret .= $this->defines->getAboveDefines('Status'); $ret .= $this->defines->getDefine($language, 'STATUS_NONE', 'No status'); @@ -250,7 +245,6 @@ public function getLanguageAdminClass($language, $tables) $ret .= $this->defines->getDefine($language, 'BROKEN_KEYVAL', 'Key value'); $ret .= $this->defines->getDefine($language, 'BROKEN_MAIN', 'Info main'); } - if ($fieldSampleListValue > 0) { $ret .= $this->defines->getAboveDefines('Sample List Values'); $ret .= $this->defines->getDefine($language, 'LIST_1', 'Sample List Value 1'); diff --git a/class/Files/Language/LanguageMailTpl.php b/class/Files/Language/LanguageMailTpl.php index d531e505..607c577a 100644 --- a/class/Files/Language/LanguageMailTpl.php +++ b/class/Files/Language/LanguageMailTpl.php @@ -82,10 +82,10 @@ public function getTemplateDummy($tableSoleName, $stuTableSoleName, $stuFieldMai $ret = $this->getSimpleString('Hello {X_UNAME},'); $ret .= $this->getSimpleString(''); - $ret .= $this->getSimpleString('A new ' . $tableSoleName . ' "{' . $stuFieldMain . '}" has been added at {X_SITENAME}.'); + $ret .= $this->getSimpleString('A new ' . $tableSoleName . ' "{ITEM_NAME}" has been added at {X_SITENAME}.'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString('You can view this ' . $tableSoleName . ' here:'); - $ret .= $this->getSimpleString('{' . $stuTableSoleName . '_URL}'); + $ret .= $this->getSimpleString('{ITEM_URL}'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString($line); $ret .= $this->getSimpleString(''); @@ -108,10 +108,10 @@ public function getTemplateTableNew($tableSoleName, $stuTableSoleName, $stuField $ret = $this->getSimpleString('Hello {X_UNAME},'); $ret .= $this->getSimpleString(''); - $ret .= $this->getSimpleString('A new ' . $tableSoleName . ' "{' . $stuFieldMain . '}" has been added at {X_SITENAME}.'); + $ret .= $this->getSimpleString('A new ' . $tableSoleName . ' "{ITEM_NAME}" has been added at {X_SITENAME}.'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString('You can view this ' . $tableSoleName . ' here:'); - $ret .= $this->getSimpleString('{' . $stuTableSoleName . '_URL}'); + $ret .= $this->getSimpleString('{ITEM_URL}'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString($line); $ret .= $this->getSimpleString(''); @@ -133,10 +133,10 @@ public function getTemplateTableModify($tableSoleName, $stuTableSoleName, $stuFi $ret = $this->getSimpleString('Hello {X_UNAME},'); $ret .= $this->getSimpleString(''); - $ret .= $this->getSimpleString('The ' . $tableSoleName . ' "{' . $stuFieldMain . '}" has been modified at {X_SITENAME}.'); + $ret .= $this->getSimpleString('The ' . $tableSoleName . ' "{ITEM_NAME}" has been modified at {X_SITENAME}.'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString('You can view this ' . $tableSoleName . ' here:'); - $ret .= $this->getSimpleString('{' . $stuTableSoleName . '_URL}'); + $ret .= $this->getSimpleString('{ITEM_URL}'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString($line); $ret .= $this->getSimpleString(''); @@ -157,7 +157,7 @@ public function getTemplateTableDelete($tableSoleName, $stuFieldMain, $line) $ret = $this->getSimpleString('Hello {X_UNAME},'); $ret .= $this->getSimpleString(''); - $ret .= $this->getSimpleString('The ' . $tableSoleName . ' "{' . $stuFieldMain . '}" has been deleted from {X_SITENAME}.'); + $ret .= $this->getSimpleString('The ' . $tableSoleName . ' "{ITEM_NAME}" has been deleted from {X_SITENAME}.'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString($line); $ret .= $this->getSimpleString(''); @@ -179,10 +179,10 @@ public function getTemplateTableApprove($tableSoleName, $stuTableSoleName, $stuF $ret = $this->getSimpleString('Hello {X_UNAME},'); $ret .= $this->getSimpleString(''); - $ret .= $this->getSimpleString('A new ' . $tableSoleName . ' "{' . $stuFieldMain . '}" is waiting for approval at {X_SITENAME}.'); + $ret .= $this->getSimpleString('A new ' . $tableSoleName . ' "{ITEM_NAME}" is waiting for approval at {X_SITENAME}.'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString('You can view this ' . $tableSoleName . ' here:'); - $ret .= $this->getSimpleString('{' . $stuTableSoleName . '_URL}'); + $ret .= $this->getSimpleString('{ITEM_URL}'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString($line); $ret .= $this->getSimpleString(''); @@ -204,10 +204,10 @@ public function getTemplateTableBroken($tableSoleName, $stuTableSoleName, $stuFi $ret = $this->getSimpleString('Hello {X_UNAME},'); $ret .= $this->getSimpleString(''); - $ret .= $this->getSimpleString('The ' . $tableSoleName . ' "{' . $stuFieldMain . '}" has been notified as broken at {X_SITENAME}.'); + $ret .= $this->getSimpleString('The ' . $tableSoleName . ' "{ITEM_NAME}" has been notified as broken at {X_SITENAME}.'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString('You can view this ' . $tableSoleName . ' here:'); - $ret .= $this->getSimpleString('{' . $stuTableSoleName . '_URL}'); + $ret .= $this->getSimpleString('{ITEM_URL}'); $ret .= $this->getSimpleString(''); $ret .= $this->getSimpleString($line); $ret .= $this->getSimpleString(''); @@ -358,7 +358,6 @@ public function render() $filename = $this->getFileName(); $table = $this->getTable(); $moduleDirname = $module->getVar('mod_dirname'); - $tableName = $table->getVar('table_name'); $tableSoleName = $table->getVar('table_solename'); $stuTableSoleName = mb_strtoupper($tableSoleName); $fieldMain = ''; diff --git a/class/Files/Language/LanguageModinfo.php b/class/Files/Language/LanguageModinfo.php index 79b02d4a..52b8c27e 100644 --- a/class/Files/Language/LanguageModinfo.php +++ b/class/Files/Language/LanguageModinfo.php @@ -288,8 +288,10 @@ private function getLanguageConfig($language, $tables) // if (0 != $tables[$i]->getVar('table_permissions')) {$usePermissions = true;} } if ($fieldEditor) { - $ret .= $df->getDefine($language, 'EDITOR_DEFAULT', 'Editor'); - $ret .= $df->getDefine($language, 'EDITOR_DEFAULT_DESC', 'Select the editor which should be used for text area fields'); + $ret .= $df->getDefine($language, 'EDITOR_ADMIN', 'Editor admin'); + $ret .= $df->getDefine($language, 'EDITOR_ADMIN_DESC', 'Select the editor which should be used in admin area for text area fields'); + $ret .= $df->getDefine($language, 'EDITOR_USER', 'Editor user'); + $ret .= $df->getDefine($language, 'EDITOR_USER_DESC', 'Select the editor which should be used in user area for text area fields'); $ret .= $df->getDefine($language, 'EDITOR_MAXCHAR', 'Text max characters'); $ret .= $df->getDefine($language, 'EDITOR_MAXCHAR_DESC', 'Max characters for showing text of a textarea or editor field in admin area'); } @@ -358,8 +360,6 @@ private function getLanguageConfig($language, $tables) /** * @private function getLanguageNotificationsGlobal * @param $language - * @param mixed $tableSoleName - * * @return string */ private function getLanguageNotificationsGlobal($language) @@ -405,6 +405,7 @@ private function getLanguageNotificationsGlobal($language) /** * @private function getLanguageNotificationsTable * @param $language + * @param $tableName * @param mixed $tableSoleName * * @return string diff --git a/class/Files/Templates/Admin/TemplatesAdminBroken.php b/class/Files/Templates/Admin/TemplatesAdminBroken.php index b7233214..b7def0ab 100644 --- a/class/Files/Templates/Admin/TemplatesAdminBroken.php +++ b/class/Files/Templates/Admin/TemplatesAdminBroken.php @@ -58,7 +58,7 @@ public static function getInstance() /** * @public function write * @param string $module - * @param string $table + * @param $tables * @param $filename */ public function write($module, $tables, $filename) @@ -85,10 +85,8 @@ private function getTemplatesAdminBrokenHeader($moduleDirname) /** * @private function getTemplatesAdminBrokenTableThead - * @param $tableSoleName - * @param $tableAutoincrement - * @param string $fields * @param string $language + * @param $t * @return string */ private function getTemplatesAdminBrokenTableThead($language, $t) @@ -111,11 +109,9 @@ private function getTemplatesAdminBrokenTableThead($language, $t) /** * @private function getTemplatesAdminBrokenTableTBody - * @param string $moduleDirname * @param string $tableName * @param $tableSoleName - * @param $tableAutoincrement - * @param string $fields + * @param $language * @return string * @internal param string $language */ @@ -154,8 +150,6 @@ private function getTemplatesAdminBrokenTableTBody($tableName, $tableSoleName, $ * @param string $moduleDirname * @param string $tableName * @param $tableSoleName - * @param $tableAutoincrement - * @param string $fields * @param string $language * @return string */ @@ -172,11 +166,9 @@ private function getTemplatesAdminBrokenTable($moduleDirname, $tableName, $table /** * @private function getTemplatesAdminBrokenList * @param string $moduleDirname - * @param string $tableName - * @param $tableSoleName - * @param $tableAutoincrement - * @param string $fields + * @param $table * @param string $language + * @param string $t * @return string */ private function getTemplatesAdminBrokenList($moduleDirname, $table, $language, $t = '') diff --git a/class/Files/Templates/User/Defstyle/Breadcrumbs.php b/class/Files/Templates/User/Defstyle/Breadcrumbs.php index 2b4b6e24..3b82f269 100644 --- a/class/Files/Templates/User/Defstyle/Breadcrumbs.php +++ b/class/Files/Templates/User/Defstyle/Breadcrumbs.php @@ -43,8 +43,7 @@ public function __construct() /** * @static function getInstance - * @param null - * @return User\Breadcrumbs + * @return bool|Breadcrumbs */ public static function getInstance() { diff --git a/class/Files/Templates/User/Defstyle/Categories.php b/class/Files/Templates/User/Defstyle/Categories.php index b37e1b47..0473edcf 100644 --- a/class/Files/Templates/User/Defstyle/Categories.php +++ b/class/Files/Templates/User/Defstyle/Categories.php @@ -43,8 +43,7 @@ public function __construct() /** * @static function getInstance - * @param null - * @return User\Categories + * @return bool|Categories */ public static function getInstance() { diff --git a/class/Files/Templates/User/Defstyle/CategoriesList.php b/class/Files/Templates/User/Defstyle/CategoriesList.php index 8f0759f8..8ed61f6b 100644 --- a/class/Files/Templates/User/Defstyle/CategoriesList.php +++ b/class/Files/Templates/User/Defstyle/CategoriesList.php @@ -43,8 +43,7 @@ public function __construct() /** * @static function getInstance - * @param null - * @return User\CategoriesList + * @return bool|CategoriesList */ public static function getInstance() { diff --git a/class/Files/Templates/User/Defstyle/Footer.php b/class/Files/Templates/User/Defstyle/Footer.php index c0a87cfa..ff6e4ce4 100644 --- a/class/Files/Templates/User/Defstyle/Footer.php +++ b/class/Files/Templates/User/Defstyle/Footer.php @@ -97,7 +97,8 @@ public function getTemplateUserFooterFacebookShareButton() /** * @public function render - * @param null + * @param $moduleDirname + * @param $language * @return bool|string */ private function getTemplateUserFooterContent($moduleDirname, $language) diff --git a/class/Files/Templates/User/Defstyle/Pages.php b/class/Files/Templates/User/Defstyle/Pages.php index 3de9227e..ff8f21df 100644 --- a/class/Files/Templates/User/Defstyle/Pages.php +++ b/class/Files/Templates/User/Defstyle/Pages.php @@ -176,10 +176,7 @@ private function getTemplatesUserPages($moduleDirname, $tableName, $tableSoleNam /** * @private function getTemplatesUserPagesForm - * @param $moduleDirname - * @param $tableName - * @param $tableSoleName - * @param $language + * @param string $t * @return string */ private function getTemplatesUserPagesForm($t = '') @@ -192,10 +189,7 @@ private function getTemplatesUserPagesForm($t = '') /** * @private function getTemplatesUserPagesError - * @param $moduleDirname - * @param $tableName - * @param $tableSoleName - * @param $language + * @param string $t * @return string */ private function getTemplatesUserPagesError($t = '') diff --git a/class/Files/Templates/User/Defstyle/PagesItem.php b/class/Files/Templates/User/Defstyle/PagesItem.php index 5bd16659..9d45fc20 100644 --- a/class/Files/Templates/User/Defstyle/PagesItem.php +++ b/class/Files/Templates/User/Defstyle/PagesItem.php @@ -172,9 +172,9 @@ private function getTemplatesUserPagesItemPanel($moduleDirname, $tableId, $table $contElse = $hc->getHtmlAnchor($tableName . ".php?op=show&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-success right', '', "\t\t\t", "\n"); $anchors .= $sc->getSmartyConditions('showItem', '', '', $contIf, $contElse, '', '', "\t\t"); $lang = $sc->getSmartyConst('', '_EDIT'); - $contIf = $hc->getHtmlAnchor($tableName . ".php?op=show&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-primary right', '', "\t\t\t", "\n"); + $contIf = $hc->getHtmlAnchor($tableName . ".php?op=edit&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-primary right', '', "\t\t\t", "\n"); $lang = $sc->getSmartyConst('', '_DELETE'); - $contIf .= $hc->getHtmlAnchor($tableName . ".php?op=show&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-danger right', '', "\t\t\t", "\n"); + $contIf .= $hc->getHtmlAnchor($tableName . ".php?op=delete&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-danger right', '', "\t\t\t", "\n"); $anchors .= $sc->getSmartyConditions('permEdit', '', '', $contIf, false, '', '', "\t\t"); $lang = $sc->getSmartyConst($language, 'BROKEN'); $anchors .= $hc->getHtmlAnchor($tableName . ".php?op=broken&{$fieldId}=" . $keyDouble, $lang, $lang, '', 'btn btn-warning right', '', "\t\t", "\n"); diff --git a/class/Files/Templates/User/Defstyle/PagesList.php b/class/Files/Templates/User/Defstyle/PagesList.php index af87e774..400fc012 100644 --- a/class/Files/Templates/User/Defstyle/PagesList.php +++ b/class/Files/Templates/User/Defstyle/PagesList.php @@ -173,11 +173,11 @@ private function getTemplatesUserPagesListPanel($moduleDirname, $tableId, $table /** * @private function getTemplatesUserPagesListPanel * @param string $moduleDirname - * @param $tableId - * @param $tableMid * @param $tableName * @param $tableSoleName - * @param $language + * @param $fieldElement + * @param $fieldName + * @param $rpFieldName * @return string */ private function getElement($moduleDirname, $tableName, $tableSoleName, $fieldElement, $fieldName, $rpFieldName) diff --git a/class/Files/User/UserPages.php b/class/Files/User/UserPages.php index 543906d6..2c9c2c39 100644 --- a/class/Files/User/UserPages.php +++ b/class/Files/User/UserPages.php @@ -90,7 +90,7 @@ private function getUserPagesHeader($moduleDirname, $tableName, $fieldId) $ret .= $uxc->getUserTplMain($moduleDirname, $tableName); $ret .= $pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'header', true); $ret .= $pc->getPhpCodeBlankLine(); - $ret .= $xc->getXcXoopsRequest('op ', 'op', 'list', 'String'); + $ret .= $xc->getXcXoopsRequest('op ', 'op', 'list', 'Cmd'); $ret .= $xc->getXcXoopsRequest('start', 'start', '0', 'Int'); $userpager = $xc->getXcGetConfig('userpager'); $ret .= $xc->getXcXoopsRequest('limit', 'limit', $userpager, 'Int'); @@ -165,15 +165,44 @@ private function getUserPagesList($tableName, $fieldId, $fieldMain, $t = '') * @param string $tableName * @param $tableSoleName * @param $tablePermissions + * @param $tableNotifications * @param $language * @param string $t * @return string */ - public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSoleName, $tablePermissions, $language, $t = '') + public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSoleName, $tablePermissions, $tableNotifications, $language, $t = '') { $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); + $ucfTableName = ucfirst($tableName); + $countUploader = 0; + $fieldId = ''; + $ccFieldId = ''; + $fieldMain = ''; + $fieldStatus = ''; + foreach (array_keys($fields) as $f) { + $fieldName = $fields[$f]->getVar('field_name'); + if (0 == $f) { + $fieldId = $fieldName; + $ccFieldId = $this->getCamelCase($fieldId, false, true); + $ucfFieldId = ucfirst($ccFieldId); + } + if ($fields[$f]->getVar('field_type') >= 10 && $fields[$f]->getVar('field_type') <= 14) { + $countUploader++; + } + if (1 == $fields[$f]->getVar('field_main')) { + $fieldMain = $fieldName; // fieldMain = fields parameters main field + $stuFieldMain = mb_strtoupper($fieldMain); + $ccFieldMain = $this->getCamelCase($fieldMain, false, true); + } + if ($fields[$f]->getVar('field_element') == 16) { + $fieldStatus = $fieldName; + $ccFieldStatus = $this->getCamelCase($fieldStatus, false, true); + + } + } + $ret = $pc->getPhpCodeCommentLine('Security Check', '', $t); $xoopsSecurityCheck = $xc->getXcXoopsSecurityCheck(); $securityError = $xc->getXcXoopsSecurityErrors(); @@ -183,40 +212,64 @@ public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSole $ret .= $pc->getPhpCodeCommentLine('Check permissions', '', $t); $contIf = $xc->getXcRedirectHeader($tableName, '?op=list', 3, '_NOPERM', true, $t . "\t"); $ret .= $pc->getPhpCodeConditions('!$permissionsHandler->getPermGlobalSubmit()', '', '', $contIf, false, $t); - $ret .= $xc->getXcHandlerCreateObj($tableName, $t); + $getObj = $xc->getXcHandlerGetObj($tableName, $ccFieldId, $t . "\t"); + $createObj = $xc->getXcHandlerCreateObj($tableName, $t . "\t"); + $ret .= $pc->getPhpCodeConditions("\${$ccFieldId}", ' > ', '0', $getObj, $createObj, $t); $ret .= $xc->getXcSaveElements($moduleDirname, $tableName, $tableSoleName, $fields, $t); $ret .= $pc->getPhpCodeCommentLine('Insert Data', null, $t); $insert = $xc->getXcHandlerInsert($tableName, $tableName, 'Obj', 'Handler'); - $countUploader = 0; - $fieldId = ''; - $ccFieldId = ''; - foreach (array_keys($fields) as $f) { - $fieldName = $fields[$f]->getVar('field_name'); - if (0 == $f) { - $fieldId = $fieldName; - $ccFieldId = $this->getCamelCase($fieldId, false, true); - } - if ($fields[$f]->getVar('field_type') >= 10 && $fields[$f]->getVar('field_type') <= 14) { - $countUploader++; - } - } + $contentInsert = ''; + $contentInsert .= $pc->getPhpCodeTernaryOperator("new{$ucfFieldId}", "\${$ccFieldId} > 0", "\${$ccFieldId}", "\${$tableName}Obj->getNewInsertedId{$ucfTableName}()", $t . "\t"); + if (1 == $tablePermissions) { - $ucfTableName = ucfirst($tableName); - $ucfFieldId = $this->getCamelCase($fieldId, true); - $contentInsert .= $xc->getXcEqualsOperator("\$new{$ucfFieldId}", "\${$tableName}Obj->getNewInsertedId{$ucfTableName}()", null, $t . "\t"); - $contentInsert .= $pc->getPhpCodeTernaryOperator('permId', "isset(\$_REQUEST['{$fieldId}'])", "\${$ccFieldId}", "\$new{$ucfFieldId}", $t . "\t"); $contentInsert .= $xc->getXcXoopsHandler('groupperm', $t . "\t"); $contentInsert .= $xc->getXcEqualsOperator('$mid', "\$GLOBALS['xoopsModule']->getVar('mid')", null, $t . "\t"); - $contentInsert .= $this->getPermissionsSave($moduleDirname, 'view_' . $tableName); - $contentInsert .= $this->getPermissionsSave($moduleDirname, 'submit_' . $tableName); - $contentInsert .= $this->getPermissionsSave($moduleDirname, 'approve_' . $tableName); + $contentInsert .= $this->getPermissionsSave($moduleDirname, $ucfFieldId,'view_' . $tableName); + $contentInsert .= $this->getPermissionsSave($moduleDirname, $ucfFieldId, 'submit_' . $tableName); + $contentInsert .= $this->getPermissionsSave($moduleDirname, $ucfFieldId, 'approve_' . $tableName); } + if (1 == $tableNotifications) { + $contentInsert .= $pc->getPhpCodeCommentLine('Handle notification', null, $t . "\t"); + $contentInsert .= $xc->getXcGetVar($ccFieldMain, "{$tableName}Obj", $fieldMain, false, $t. "\t"); + if ('' !== $fieldStatus) { + $contentInsert .= $xc->getXcGetVar($ccFieldStatus, "{$tableName}Obj", $fieldStatus, false, $t . "\t"); + } + $contentInsert .= $pc->getPhpCodeArray('tags', [], false, $t . "\t"); + $contentInsert .= $xc->getXcEqualsOperator("\$tags['ITEM_NAME']", "\${$ccFieldMain}", '', $t . "\t"); + $url = "XOOPS_URL . '/modules/{$moduleDirname}/{$tableName}.php?op=show&{$fieldId}=' . \${$ccFieldId}"; + $contentInsert .= $xc->getXcEqualsOperator("\$tags['ITEM_URL'] ", $url, '', $t . "\t"); + $contentInsert .= $xc->getXcXoopsHandler('notification', $t . "\t"); + if ('' === $fieldStatus) { + $not2If = $pc->getPhpCodeCommentLine('Event modify notification', null, $t . "\t\t"); + $not2If .= $this->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_modify', \$tags);", $t . "\t\t"); + $not2If .= $this->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \$new{$ucfFieldId}, '{$tableSoleName}_modify', \$tags);", $t . "\t\t"); + $not2Else = $pc->getPhpCodeCommentLine('Event new notification', null, $t . "\t\t"); + $not2Else .= $this->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_new', \$tags);", $t . "\t\t"); + $not2Else .= $this->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \$new{$ucfFieldId}, '{$tableSoleName}_new', \$tags);", $t . "\t\t"); + $not1Else = $pc->getPhpCodeConditions("\${$ccFieldId}", ' > ', '0', $not2If, $not2Else, $t . "\t"); + $contentInsert .= $not1Else; + } else { + $not1If = $pc->getPhpCodeCommentLine('Event approve notification', null, $t . "\t\t"); + $not1If .= $this->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_approve', \$tags);", $t . "\t\t"); + $not1If .= $this->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \$new{$ucfFieldId}, '{$tableSoleName}_approve', \$tags);", $t . "\t\t"); + $not2If = $pc->getPhpCodeCommentLine('Event modify notification', null, $t . "\t\t\t"); + $not2If .= $this->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_modify', \$tags);", $t . "\t\t\t"); + $not2If .= $this->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \$new{$ucfFieldId}, '{$tableSoleName}_modify', \$tags);", $t . "\t\t\t"); + $not2Else = $pc->getPhpCodeCommentLine('Event new notification', null, $t . "\t\t\t"); + $not2Else .= $this->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_new', \$tags);", $t . "\t\t\t"); + $not2Else .= $this->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \$new{$ucfFieldId}, '{$tableSoleName}_new', \$tags);", $t . "\t\t\t"); + $not1Else = $pc->getPhpCodeConditions("\${$ccFieldId}", ' > ', '0', $not2If, $not2Else, $t . "\t\t"); + $contentInsert .= $pc->getPhpCodeConditions("\${$ccFieldStatus}", ' == ', $xc->getXcGetConstants('STATUS_APPROVED'), $not1If, $not1Else, $t . "\t"); + } + } + + $contentInsert .= $pc->getPhpCodeCommentLine('redirect after insert', null, $t . "\t"); if ($countUploader > 0) { - $errIf = $xc->getXcRedirectHeader("'{$tableName}.php?op=edit&{$fieldId}=' . \${$ccFieldId}", '', '5', '$uploaderErrors', false, $t . "\t\t"); + $errIf = $xc->getXcRedirectHeader("'{$tableName}.php?op=edit&{$fieldId}=' . \$new{$ucfFieldId}", '', '5', '$uploaderErrors', false, $t . "\t\t"); $errElse = $xc->getXcRedirectHeader($tableName, '?op=list', '2', "{$language}FORM_OK", true, $t . "\t\t"); - $confirmOk = $pc->getPhpCodeConditions("''", ' !== ', '$uploaderErrors', $errIf, $errElse, $t . "\t"); + $confirmOk = $pc->getPhpCodeConditions('$uploaderErrors', ' !== ', "''", $errIf, $errElse, $t . "\t"); } else { $confirmOk = $xc->getXcRedirectHeader('index', '', '2', "{$language}FORM_OK", true, $t . "\t"); } @@ -226,7 +279,7 @@ public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSole $ret .= $pc->getPhpCodeCommentLine('Get Form Error', null, $t); $ret .= $xc->getXcXoopsTplAssign('error', "\${$tableName}Obj->getHtmlErrors()", true, $t); $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); - $ret .= $xc->getXcXoopsTplAssign('form', '$form->display()', true, $t); + $ret .= $xc->getXcXoopsTplAssign('form', '$form->render()', true, $t); return $ret; } @@ -234,18 +287,19 @@ public function getUserPagesSave($moduleDirname, $fields, $tableName, $tableSole /** * @private function getPermissionsSave * @param $moduleDirname + * @param $ucfFieldId * @param string $perm * * @return string */ - private function getPermissionsSave($moduleDirname, $perm = 'view') + private function getPermissionsSave($moduleDirname, $ucfFieldId, $perm = 'view') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); $ret = $pc->getPhpCodeCommentLine('Permission to', $perm, "\t\t\t"); - $ret .= $xc->getXcDeleteRight('grouppermHandler', "{$moduleDirname}_{$perm}", '$mid', '$permId', false, "\t\t\t"); - $content = $xc->getXcAddRight('grouppermHandler', "{$moduleDirname}_{$perm}", '$permId', '$onegroupId', '$mid', false, "\t\t\t\t\t"); + $ret .= $xc->getXcDeleteRight('grouppermHandler', "{$moduleDirname}_{$perm}", '$mid', "\$new{$ucfFieldId}", false, "\t\t\t"); + $content = $xc->getXcAddRight('grouppermHandler', "{$moduleDirname}_{$perm}", "\$new{$ucfFieldId}", '$onegroupId', '$mid', false, "\t\t\t\t\t"); $foreach = $pc->getPhpCodeForeach("_POST['groups_{$perm}']", false, false, 'onegroupId', $content, "\t\t\t\t"); $ret .= $pc->getPhpCodeConditions("isset(\$_POST['groups_{$perm}'])", null, null, $foreach, false, "\t\t\t"); @@ -299,13 +353,15 @@ public function getUserPagesEdit($tableName, $fieldId, $language, $t = '') /** * @private function getUserPagesDelete * @param $tableName + * @param $tableSoleName * @param $language * @param $fieldId * @param $fieldMain + * @param $tableNotifications * @param string $t * @return string */ - private function getUserPagesDelete($tableName, $language, $fieldId, $fieldMain, $t = '') + private function getUserPagesDelete($tableName, $tableSoleName, $language, $fieldId, $fieldMain, $tableNotifications, $t = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); @@ -317,7 +373,7 @@ private function getUserPagesDelete($tableName, $language, $fieldId, $fieldMain, $ret .= $pc->getPhpCodeCommentLine('Check params', '', $t); $contIf = $xc->getXcRedirectHeader($tableName, '?op=list', 3, "{$language}INVALID_PARAM", true, $t . "\t"); $ret .= $pc->getPhpCodeConditions("\${$ccFieldId}", ' == ', '0', $contIf, false, $t); - $ret .= $xc->getXcCommonPagesDelete($language, $tableName, $fieldId, $fieldMain, $t); + $ret .= $xc->getXcCommonPagesDelete($language, $tableName, $tableSoleName, $fieldId, $fieldMain, $tableNotifications, $t); return $ret; } @@ -331,58 +387,44 @@ private function getUserPagesDelete($tableName, $language, $fieldId, $fieldMain, * @param $fieldId * @param $fieldSatus * @param $fieldMain + * @param $tableNotifications * @param string $t * @return string */ - private function getUserPagesBroken($language, $moduleDirname, $tableName, $tableSoleName, $fieldId, $fieldSatus, $fieldMain, $t = '') + private function getUserPagesBroken($language, $moduleDirname, $tableName, $tableSoleName, $fieldId, $fieldSatus, $fieldMain, $tableNotifications, $t = '') { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); - $stuFieldMain = mb_strtoupper($fieldMain); - $stuTableSoleName = mb_strtoupper($tableSoleName); + //$stuFieldMain = mb_strtoupper($fieldMain); + //$stuTableSoleName = mb_strtoupper($tableSoleName); $ccFieldId = $this->getCamelCase($fieldId, false, true); $ccFieldMain = $this->getCamelCase($fieldMain, false, true); - $ret = $pc->getPhpCodeCommentLine('Check params', '', $t); - $contIf = $xc->getXcRedirectHeader($tableName, '?op=list', 3, "{$language}INVALID_PARAM", true, $t . "\t"); - $ret .= $pc->getPhpCodeConditions("\${$ccFieldId}", ' == ', '0', $contIf, false, $t); - - $ret .= $this->getSimpleString('$error = false;', $t); - $ret .= $this->getSimpleString("\$errorMessage = '';", $t); - $ret .= $pc->getPhpCodeCommentLine('Test first the validation', null, $t); - $ret .= $xc->getXcXoopsLoad('captcha', $t); - $ret .= $xc->getXcXoopsCaptcha($t); - $contIf = $xc->getXcEqualsOperator('$errorMessage', "\$xoopsCaptcha->getMessage().'
'", '.', $t . "\t"); - $contIf .= $xc->getXcXoopsTplAssign('error_message', '$errorMessage', true, $t . "\t"); - $contIf .= $this->getSimpleString('break;', $t . "\t"); - $ret .= $pc->getPhpCodeConditions('!$xoopsCaptcha->verify()', '', '', $contIf, false, $t); - + $ret = $pc->getPhpCodeCommentLine('Check params', '', $t); + $contIf = $xc->getXcRedirectHeader($tableName, '?op=list', 3, "{$language}INVALID_PARAM", true, $t . "\t"); + $ret .= $pc->getPhpCodeConditions("\${$ccFieldId}", ' == ', '0', $contIf, false, $t); $ret .= $xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t); $constant = $xc->getXcGetConstants('STATUS_BROKEN'); $ret .= $xc->getXcSetVarObj($tableName, $fieldSatus, $constant, $t); $ret .= $xc->getXcGetVar($ccFieldMain, "{$tableName}Obj", $fieldMain, false, $t); $ret .= $pc->getPhpCodeCommentLine('Insert Data', null, $t); $insert = $xc->getXcHandlerInsert($tableName, $tableName, 'Obj'); - $contInsert = $pc->getPhpCodeCommentLine('Event broken notification', null, $t . "\t"); - $contInsert .= $pc->getPhpCodeArray('tags', [], false, $t . "\t"); - $contInsert .= $xc->getXcEqualsOperator("\$tags['{$stuFieldMain}']", "\${$ccFieldMain}", '', $t . "\t"); - $url = "XOOPS_URL . '/modules/{$moduleDirname}/{$tableName}.php?op=show&{$fieldId}=' . \${$ccFieldId}"; - $contInsert .= $xc->getXcEqualsOperator("\$tags['{$stuTableSoleName}_URL']", $url, '', $t . "\t"); - $contInsert .= $xc->getXcXoopsHandler('notification', $t . "\t"); - $contInsert .= $this->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_broken', \$tags);", $t . "\t"); - $contInsert .= $this->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \${$ccFieldId}, '{$tableSoleName}_broken', \$tags);", $t . "\t"); + $contInsert = ''; + if (1 == $tableNotifications) { + $contInsert .= $pc->getPhpCodeCommentLine('Event broken notification', null, $t . "\t"); + $contInsert .= $pc->getPhpCodeArray('tags', [], false, $t . "\t"); + $contInsert .= $xc->getXcEqualsOperator("\$tags['ITEM_NAME']", "\${$ccFieldMain}", '', $t . "\t"); + $url = "XOOPS_URL . '/modules/{$moduleDirname}/{$tableName}.php?op=show&{$fieldId}=' . \${$ccFieldId}"; + $contInsert .= $xc->getXcEqualsOperator("\$tags['ITEM_URL'] ", $url, '', $t . "\t"); + $contInsert .= $xc->getXcXoopsHandler('notification', $t . "\t"); + $contInsert .= $this->getSimpleString("\$notificationHandler->triggerEvent('global', 0, 'global_broken', \$tags);", $t . "\t"); + $contInsert .= $this->getSimpleString("\$notificationHandler->triggerEvent('{$tableName}', \${$ccFieldId}, '{$tableSoleName}_broken', \$tags);", $t . "\t"); + } $contInsert .= $pc->getPhpCodeCommentLine('redirect after success', null, $t . "\t"); $contInsert .= $xc->getXcRedirectHeader($tableName, '', '2', "{$language}FORM_OK", true, $t . "\t"); $ret .= $pc->getPhpCodeConditions($insert, '', '', $contInsert, false, $t); - $ret .= $pc->getPhpCodeBlankLine(); - $ret .= $pc->getPhpCodeCommentLine('Get Form Error', null, $t); - $ret .= $xc->getXcXoopsTplAssign('error', "\${$tableName}Obj->getHtmlErrors()", true, $t); - $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); - $ret .= $xc->getXcXoopsTplAssign('form', '$form->display()', true, $t); - $ret .= $pc->getPhpCodeBlankLine(); - return $ret; } @@ -432,11 +474,12 @@ private function getUserPagesFooter($moduleDirname, $tableName, $language) * @param $fieldId * @param $fieldMain * @param $fieldSatus + * @param $tableNotifications * @param $language * @param $t * @return string */ - private function getUserPagesSwitch($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableSubmit, $tablePermissions, $tableBroken, $fieldId, $fieldMain, $fieldSatus, $language, $t) + private function getUserPagesSwitch($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableSubmit, $tablePermissions, $tableBroken, $fieldId, $fieldMain, $fieldSatus, $tableNotifications, $language, $t) { $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); @@ -444,13 +487,13 @@ private function getUserPagesSwitch($moduleDirname, $tableId, $tableMid, $tableN $cases['show'] = []; $cases['list'] = [$this->getUserPagesList($tableName, $fieldId, $fieldMain, $t . "\t")]; if (1 == $tableSubmit) { - $cases['save'] = [$this->getUserPagesSave($moduleDirname, $fields, $tableName, $tableSoleName, $tablePermissions, $language, $t . "\t")]; + $cases['save'] = [$this->getUserPagesSave($moduleDirname, $fields, $tableName, $tableSoleName, $tablePermissions, $tableNotifications, $language, $t . "\t")]; $cases['new'] = [$this->getUserPagesNew($tableName, $t . "\t")]; $cases['edit'] = [$this->getUserPagesEdit($tableName, $fieldId, $language, $t . "\t")]; - $cases['delete'] = [$this->getUserPagesDelete($tableName, $language, $fieldId, $fieldMain,$t . "\t")]; + $cases['delete'] = [$this->getUserPagesDelete($tableName, $tableSoleName, $language, $fieldId, $fieldMain, $tableNotifications,$t . "\t")]; } if (1 == $tableBroken) { - $cases['broken'] = [$this->getUserPagesBroken($language, $moduleDirname, $tableName, $tableSoleName, $fieldId, $fieldSatus, $fieldMain, $t . "\t")]; + $cases['broken'] = [$this->getUserPagesBroken($language, $moduleDirname, $tableName, $tableSoleName, $fieldId, $fieldSatus, $fieldMain, $tableNotifications, $t . "\t")]; } return $xc->getXcSwitch('op', $cases, true, false); @@ -463,18 +506,19 @@ private function getUserPagesSwitch($moduleDirname, $tableId, $tableMid, $tableN */ public function render() { - $module = $this->getModule(); - $table = $this->getTable(); - $tableId = $table->getVar('table_id'); - $tableMid = $table->getVar('table_mid'); - $tableName = $table->getVar('table_name'); - $tableSubmit = $table->getVar('table_submit'); - $tablePermissions = $table->getVar('table_permissions'); - $tableSoleName = $table->getVar('table_solename'); - $tableBroken = $table->getVar('table_broken'); - $filename = $this->getFileName(); - $moduleDirname = $module->getVar('mod_dirname'); - $language = $this->getLanguage($moduleDirname, 'MA'); + $module = $this->getModule(); + $table = $this->getTable(); + $tableId = $table->getVar('table_id'); + $tableMid = $table->getVar('table_mid'); + $tableName = $table->getVar('table_name'); + $tableSubmit = $table->getVar('table_submit'); + $tablePermissions = $table->getVar('table_permissions'); + $tableSoleName = $table->getVar('table_solename'); + $tableBroken = $table->getVar('table_broken'); + $tableNotifications = $table->getVar('table_notifications'); + $filename = $this->getFileName(); + $moduleDirname = $module->getVar('mod_dirname'); + $language = $this->getLanguage($moduleDirname, 'MA'); // Fields $fieldId = ''; $fieldMain = ''; @@ -494,7 +538,7 @@ public function render() } $content = $this->getHeaderFilesComments($module); $content .= $this->getUserPagesHeader($moduleDirname, $tableName, $fieldId); - $content .= $this->getUserPagesSwitch($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableSubmit, $tablePermissions, $tableBroken, $fieldId, $fieldMain, $fieldSatus, $language, "\t"); + $content .= $this->getUserPagesSwitch($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableSubmit, $tablePermissions, $tableBroken, $fieldId, $fieldMain, $fieldSatus, $tableNotifications, $language, "\t"); $content .= $this->getUserPagesFooter($moduleDirname, $tableName, $language); $this->create($moduleDirname, '/', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED); diff --git a/class/Files/User/UserRate.php b/class/Files/User/UserRate.php index c4920fff..fde26e25 100644 --- a/class/Files/User/UserRate.php +++ b/class/Files/User/UserRate.php @@ -105,7 +105,7 @@ public function getUserRateHeader($moduleDirname, $tableName) $ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname], '', ''); $ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']); $ret .= $this->getInclude(); - $ret .= $this->xc->getXcXoopsRequest('op', 'op', 'form'); + $ret .= $this->xc->getXcXoopsRequest('op', 'op', 'form', 'Cmd'); $ret .= $this->xc->getXcXoopsRequest('lid', 'lid', '', 'Int'); $ret .= $this->uxc->getUserTplMain($moduleDirname, $tableName); $ret .= $this->pc->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'header', true); @@ -193,7 +193,7 @@ public function getUserRateSave($moduleDirname, $fields, $tableName, $tableSoleN $ret .= $this->pc->getPhpCodeCommentLine('Get Form Error', null, "\t\t"); $ret .= $this->xc->getXcXoopsTplAssign('error', "\${$tableName}Obj->getHtmlErrors()", true, "\t\t"); $ret .= $this->xc->getXcGetForm('form', $tableName, 'Obj', "\t\t"); - $ret .= $this->xc->getXcXoopsTplAssign('form', '$form->display()', true, "\t\t"); + $ret .= $this->xc->getXcXoopsTplAssign('form', '$form->render()', true, "\t\t"); return $ret; } diff --git a/class/Files/User/UserXoopsVersion.php b/class/Files/User/UserXoopsVersion.php index 1f091708..ab96d02d 100644 --- a/class/Files/User/UserXoopsVersion.php +++ b/class/Files/User/UserXoopsVersion.php @@ -505,7 +505,7 @@ private function getXoopsVersionConfig($module, $tables, $language) $table_uploadfile = 0; foreach ($tables as $table) { $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); - $stuTablename = mb_strtoupper($table->getVar('table_name')); + //$stuTablename = mb_strtoupper($table->getVar('table_name')); foreach (array_keys($fields) as $f) { $fieldElement = (int)$fields[$f]->getVar('field_element'); switch ($fieldElement) { @@ -543,17 +543,30 @@ private function getXoopsVersionConfig($module, $tables, $language) } } if (1 === $table_editors) { - $fieldName = $fields[$f]->getVar('field_name'); - $rpFieldName = $this->getRightString($fieldName); - $ucfFieldName = ucfirst($rpFieldName); - $stuFieldName = mb_strtoupper($rpFieldName); - $ret .= $pc->getPhpCodeCommentLine('Editor', ''); + //$fieldName = $fields[$f]->getVar('field_name'); + //$rpFieldName = $this->getRightString($fieldName); + //$ucfFieldName = ucfirst($rpFieldName); + //$stuFieldName = mb_strtoupper($rpFieldName); + $ret .= $pc->getPhpCodeCommentLine('Editor Admin', ''); $ret .= $xc->getXcXoopsLoad('xoopseditorhandler'); $ret .= $xc->getXcEqualsOperator('$editorHandler', 'XoopsEditorHandler::getInstance()'); $editor = [ - 'name' => "'editor_default'", - 'title' => "'{$language}EDITOR_DEFAULT'", - 'description' => "'{$language}EDITOR_DEFAULT_DESC'", + 'name' => "'editor_admin'", + 'title' => "'{$language}EDITOR_ADMIN'", + 'description' => "'{$language}EDITOR_ADMIN_DESC'", + 'formtype' => "'select'", + 'valuetype' => "'text'", + 'default' => "'dhtml'", + 'options' => 'array_flip($editorHandler->getList())', + ]; + $ret .= $uxc->getUserModVersionArray(2, $editor, 'config'); + $ret .= $pc->getPhpCodeCommentLine('Editor User', ''); + $ret .= $xc->getXcXoopsLoad('xoopseditorhandler'); + $ret .= $xc->getXcEqualsOperator('$editorHandler', 'XoopsEditorHandler::getInstance()'); + $editor = [ + 'name' => "'editor_user'", + 'title' => "'{$language}EDITOR_USER'", + 'description' => "'{$language}EDITOR_USER_DESC'", 'formtype' => "'select'", 'valuetype' => "'text'", 'default' => "'dhtml'", @@ -937,7 +950,7 @@ private function getXoopsVersionNotifications($module, $language) $tableSubmit = []; $tableId = null; $tableMid = null; - $tableSoleName = ''; + //$tableSoleName = ''; $notifyCategory = ''; $notifyEvent =''; @@ -961,13 +974,13 @@ private function getXoopsVersionNotifications($module, $language) $fieldParent = null; foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); - $fieldElement = $fields[$f]->getVar('field_element'); + //$fieldElement = $fields[$f]->getVar('field_element'); if (0 == $f) { $fieldId = $fieldName; } - if ($fieldElement > 16) { - $fieldParent = $fieldName; - } + //if ($fieldElement > 16) { + // $fieldParent = $fieldName; + //} } if (1 == $tables[$t]->getVar('table_single')) { $single = $tableName; @@ -1032,7 +1045,6 @@ private function getXoopsVersionNotifications($module, $language) * @param $title * @param $from * - * @param $num * @return string */ private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from) @@ -1062,9 +1074,9 @@ private function getXoopsVersionNotificationGlobal($language, $type, $name, $tit * @param $file * @param $item * @param $allow - * @param $num * @return string */ + /* private function getXoopsVersionNotificationCategory($language, $type, $name, $title, $file, $item, $allow) { $pc = Modulebuilder\Files\CreatePhpCode::getInstance(); @@ -1084,6 +1096,7 @@ private function getXoopsVersionNotificationCategory($language, $type, $name, $t return $ret; } + */ /** * @private function getXoopsVersionNotificationTableName @@ -1095,7 +1108,6 @@ private function getXoopsVersionNotificationCategory($language, $type, $name, $t * @param $item * @param $allow * - * @param $num * @return string */ private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $file, $item, $allow) @@ -1128,7 +1140,6 @@ private function getXoopsVersionNotificationTableName($language, $type, $name, $ * @param $title * @param $mail * - * @param $num * @return string */ private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin, $title, $mail) diff --git a/class/Files/admin/AdminPages.php b/class/Files/admin/AdminPages.php index 24a0955b..a64e1a40 100644 --- a/class/Files/admin/AdminPages.php +++ b/class/Files/admin/AdminPages.php @@ -85,7 +85,7 @@ private function getAdminPagesHeader($moduleDirname, $fieldId) $ret .= $pc->getPhpCodeUseNamespace(['XoopsModules', $moduleDirname, 'Constants']); $ret .= $this->getInclude(); $ret .= $pc->getPhpCodeCommentLine('It recovered the value of argument op in URL$'); - $ret .= $xc->getXcXoopsRequest('op', 'op', 'list'); + $ret .= $xc->getXcXoopsRequest('op', 'op', 'list', 'Cmd'); $ret .= $pc->getPhpCodeCommentLine("Request {$fieldId}"); $ret .= $xc->getXcXoopsRequest($ccFieldId, $fieldId, '', 'Int'); @@ -235,11 +235,10 @@ private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $ $redirectError = $xc->getXcRedirectHeader($tableName, '', '3', $implode, true, $t . "\t"); $ret .= $pc->getPhpCodeConditions($xoopsSecurityCheck, '', '', $redirectError, false, $t); - $isset = $pc->getPhpCodeIsset($ccFieldId); - $contentIf = $xc->getXcHandlerGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t . "\t"); - $contentElse = $xc->getXcHandlerCreateObj($tableName, "\t\t\t"); - $ret .= $pc->getPhpCodeConditions($isset, '', '', $contentIf, $contentElse, $t); - $ret .= $pc->getPhpCodeCommentLine('Set Vars', null, "\t\t"); + $contentIf = $xc->getXcHandlerGetObj($tableName, $ccFieldId, $t . "\t"); + $contentElse = $xc->getXcHandlerCreateObj($tableName, $t . "\t"); + $ret .= $pc->getPhpCodeConditions("\${$ccFieldId}", ' > ', '0', $contentIf, $contentElse, $t); + $ret .= $pc->getPhpCodeCommentLine('Set Vars', null, $t); $countUploader = 0; foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); @@ -289,7 +288,7 @@ private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $ } } } - $ret .= $pc->getPhpCodeCommentLine('Insert Data', null, "\t\t"); + $ret .= $pc->getPhpCodeCommentLine('Insert Data', null, $t); $insert = $xc->getXcHandlerInsert($tableName, $tableName, 'Obj'); $contentInsert = ''; //if (1 == $tableCategory) { @@ -307,12 +306,12 @@ private function getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $ if ($countUploader > 0) { $errIf = $xc->getXcRedirectHeader("'{$tableName}.php?op=edit&{$fieldId}=' . \${$ccFieldId}", '', '5', '$uploaderErrors', false, $t . "\t\t"); $errElse = $xc->getXcRedirectHeader($tableName, '?op=list', '2', "{$language}FORM_OK", true, $t . "\t\t"); - $contentInsert .= $pc->getPhpCodeConditions("''", ' !== ', '$uploaderErrors', $errIf, $errElse, $t . "\t"); + $contentInsert .= $pc->getPhpCodeConditions('$uploaderErrors', ' !== ',"''" , $errIf, $errElse, $t . "\t"); } else { $contentInsert .= $xc->getXcRedirectHeader($tableName . '', '?op=list', '2', "{$language}FORM_OK", true, $t . "\t"); } $ret .= $pc->getPhpCodeConditions($insert, '', '', $contentInsert, false, $t); - $ret .= $pc->getPhpCodeCommentLine('Get Form', null, "\t\t"); + $ret .= $pc->getPhpCodeCommentLine('Get Form', null, $t); $ret .= $xc->getXcXoopsTplAssign('error', "\${$tableName}Obj->getHtmlErrors()", true, $t); $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); $ret .= $xc->getXcXoopsTplAssign('form', '$form->render()', true, $t); @@ -358,17 +357,19 @@ private function getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, /** * @private function getAdminPagesDelete * @param $tableName + * @param $tableSoleName * @param $language * @param $fieldId * @param $fieldMain + * @param $tableNotifications * @param string $t * @return string */ - private function getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain, $t = '') + private function getAdminPagesDelete($tableName, $tableSoleName, $language, $fieldId, $fieldMain, $tableNotifications, $t = '') { $xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); - return $xc->getXcCommonPagesDelete($language, $tableName, $fieldId, $fieldMain, $t); + return $xc->getXcCommonPagesDelete($language, $tableName, $tableSoleName, $fieldId, $fieldMain, $tableNotifications, $t, true); } /** @@ -382,18 +383,19 @@ public function render() $tf = Modulebuilder\Files\CreateFile::getInstance(); $new = $save = $edit = ''; - $module = $this->getModule(); - $table = $this->getTable(); - $filename = $this->getFileName(); - $moduleDirname = $module->getVar('mod_dirname'); - $tableName = $table->getVar('table_name'); - $tableSoleName = $table->getVar('table_solename'); - $tablePerms = $table->getVar('table_permissions'); - $language = $this->getLanguage($moduleDirname, 'AM'); - $fields = $tf->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); - $fieldInForm = null; - $fieldId = null; - $fieldMain = null; + $module = $this->getModule(); + $table = $this->getTable(); + $filename = $this->getFileName(); + $moduleDirname = $module->getVar('mod_dirname'); + $tableName = $table->getVar('table_name'); + $tableSoleName = $table->getVar('table_solename'); + $tablePerms = $table->getVar('table_permissions'); + $tableNotifications = $table->getVar('table_notifications'); + $language = $this->getLanguage($moduleDirname, 'AM'); + $fields = $tf->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); + $fieldInForm = null; + $fieldId = null; + $fieldMain = null; foreach (array_keys($fields) as $f) { $fieldName = $fields[$f]->getVar('field_name'); $fieldInForm[] = $fields[$f]->getVar('field_inform'); @@ -412,7 +414,7 @@ public function render() $save = $this->getAdminPagesSave($moduleDirname, $tableName, $tableSoleName, $language, $fields, $fieldId, $fieldMain, $tablePerms, "\t\t"); $edit = $this->getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm, "\t\t"); } - $delete = $this->getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain, "\t\t"); + $delete = $this->getAdminPagesDelete($tableName, $tableSoleName, $language, $fieldId, $fieldMain, $tableNotifications, "\t\t"); $cases = [ 'list' => [$list], diff --git a/class/Files/admin/AdminXoopsCode.php b/class/Files/admin/AdminXoopsCode.php index c94a46f3..af5074f4 100644 --- a/class/Files/admin/AdminXoopsCode.php +++ b/class/Files/admin/AdminXoopsCode.php @@ -340,7 +340,7 @@ public function getAxcSetVarPassword($tableName, $fieldName, $t = '') $ccFieldId = $cf->getCamelCase($fieldName, false, true); $ret = $xc->getXcEqualsOperator("\${$ccFieldId}", "Request::getString('{$fieldName}', '')", '',$t); $contIf = $xc->getXcSetVarObj($tableName, $fieldName, "password_hash(\${$ccFieldId}, PASSWORD_DEFAULT)", $t . "\t"); - $ret .= $pc->getPhpCodeConditions("''", ' !== ', "\${$ccFieldId}",$contIf, false, $t); + $ret .= $pc->getPhpCodeConditions("\${$ccFieldId}", ' !== ', "''", $contIf, false, $t); return $ret; } @@ -351,6 +351,7 @@ public function getAxcSetVarPassword($tableName, $fieldName, $t = '') * @param $tableName * @param $fieldName * @param $fieldType + * @param $fieldElement * @param string $t * @return string */ diff --git a/docs/changelog.txt b/docs/changelog.txt index 16148308..3f7be416 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -14,6 +14,9 @@ - switched to single editor selector (mamba/goffy) - changed constants class into interface (zyspec/goffy) - added next steps notification event (goffy) +- added notification event new, modify, approve (goffy) +- added yoda condition (goffy) +- editor admin/user (mamba/goffy)
3.03 Alpha 3 [WORK IN PROGRESS - NOT RELEASED]
Dev: XOOPS 2.5.11, PHP 7.4.5