X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fadmin-inc.php;h=18f99003fc417a312f80e05394738a35b803b343;hp=db9353b4efa08d18adf77b7624a476eb3f2d164c;hb=05ac410a5adaa49c99b6eeae4bef60f2994f1575;hpb=d6417790061e18fc1a9770ff93bb4e9d106b2f6e diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index db9353b4ef..18f99003fc 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -97,7 +97,7 @@ function ifAdminLoginDataIsValid ($adminLogin, $adminPassword) { // All fine $ret = 'done'; } else { - // Set status + // Did not match! $ret = 'password'; } } // END - if @@ -787,6 +787,15 @@ function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $ // Build a special template list function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $userid = 'userid') { + // $table and $idColumn must bove be arrays! + if (!is_array($table)) { + // $table is no array + debug_report_bug(__FUNCTION__, __LINE__, 'table[]=' . gettype($table) . '!=array'); + } elseif (!is_array($idColumn)) { + // $idColumn is no array + debug_report_bug(__FUNCTION__, __LINE__, 'idColumn[]=' . gettype($idColumn) . '!=array'); + } + $OUT = ''; // "Walk" through all entries @@ -795,7 +804,7 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $id = bigintval($id); // Get result from a given column array and table name - $result = SQL_RESULT_FROM_ARRAY($table, $columns, $idColumn, $id, __FUNCTION__, __LINE__); + $result = SQL_RESULT_FROM_ARRAY($table[0], $columns, $idColumn[0], $id, __FUNCTION__, __LINE__); // Is there one entry? if (SQL_NUMROWS($result) == 1) { @@ -833,7 +842,7 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, // Then list it $OUT .= loadTemplate(sprintf("admin_%s_%s_row", $listType, - $table + $table[0] ), true, $content ); } // END - if @@ -845,7 +854,7 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, // Load master template loadTemplate(sprintf("admin_%s_%s", $listType, - $table + $table[0] ), false, $OUT ); } @@ -1116,7 +1125,7 @@ function adminUndeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFun } // List all given rows (callback function from XML) -function adminListEntries ($tableTemplate, $rowTemplate, $tableName, $columns, $whereColumns, $orderByColumns, $callbackColumns, $extraParameters, $noEntryMessageId) { +function adminListEntries ($tableTemplate, $rowTemplate, $noEntryMessageId, $tableName, $columns, $whereColumns, $orderByColumns, $callbackColumns, $extraParameters = array()) { // Verify that tableName and columns are not empty if (count($tableName) != 1) { // No tableName specified @@ -1156,8 +1165,22 @@ function adminListEntries ($tableTemplate, $rowTemplate, $tableName, $columns, $ // Do we have entries from whereColumns to add? if (count($whereColumns) > 0) { // Then add these as well - // @TODO WHERE is not yet supported - debug_report_bug(__FUNCTION__, __LINE__, 'Unfinished area, please report your XML to the forums or bug tracker. tableTemplate=' . $tableTemplate . ',rowTemplate=' . $rowTemplate . ',tableName[0]=' . $tableName[0]); + if (count($whereColumns) == 1) { + // One entry found + $SQL .= ' WHERE '; + + // Table/alias included? + if (!empty($whereColumns[0]['table'])) { + // Add it as well + $SQL .= $whereColumns[0]['table'] . '.'; + } // END - if + + // Add the rest + $SQL .= '`' . $whereColumns[0]['column'] . '`' . $whereColumns[0]['condition'] . "'" . $whereColumns[0]['look_for'] . "'"; + } else { + // More than one entry -> Unsupported + debug_report_bug(__FUNCTION__, __LINE__, 'More than one WHERE statement found. This is currently not supported.'); + } } // END - if // Do we have entries from orderByColumns to add? @@ -1184,11 +1207,11 @@ function adminListEntries ($tableTemplate, $rowTemplate, $tableName, $columns, $ } // END - if // Now handle all over to the inner function which will execute the listing - doAdminListEntries($SQL, $tableTemplate, $rowTemplate, $callbackColumns, $extraParameters, $noEntryMessageId); + doAdminListEntries($SQL, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array()); } // Do the listing of entries -function doAdminListEntries($SQL, $tableTemplate, $rowTemplate, $callbackColumns, $extraParameters, $noEntryMessageId) { +function doAdminListEntries ($SQL, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array()) { // Run the SQL query $result = SQL_QUERY($SQL, __FUNCTION__, __LINE__); @@ -1315,12 +1338,17 @@ function doResetAdminPassword ($login, $password) { // Generate hash (we already check for sql_patches in generateHash()) $passHash = generateHash($password); + // Prepare fake POST data + $postData = array( + 'login' => array(getAdminId($login) => $login), + 'password' => array(getAdminId($login) => $passHash), + ); + // Update database - SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `password`='%s' WHERE `login`='%s' LIMIT 1", - array($passHash, $login), __FUNCTION__, __LINE__); + $message = adminsChangeAdminAccount($postData, '', false); // Run filters - runFilterChain('post_form_reset_pass', array('login' => $login, 'hash' => $passHash)); + runFilterChain('post_form_reset_pass', array('login' => $login, 'hash' => $passHash, 'message' => $message)); // Return output return '{--ADMIN_PASSWORD_RESET_DONE--}';