+
+// Reset the password for the login. Do NOT call this function without calling above function first!
+function doResetAdminPassword ($login, $password) {
+ // Init hash
+ $passHash = '';
+
+ // Now check if we have sql_patches installed
+ if (isExtensionInstalledAndNewer('sql_patches', '0.3.6')) {
+ // Use new way of hashing
+ $passHash = generateHash($password);
+ } else {
+ // Old MD5 method
+ $passHash = md5($password);
+ }
+
+ // Update database
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `password`='%s' WHERE `login`='%s' LIMIT 1",
+ array($passHash, $login), __FUNCTION__, __LINE__);
+
+ // Run filters
+ runFilterChain('post_admin_reset_pass', array('login' => $login, 'hash' => $passHash));
+
+ // Return output
+ return getMessage('ADMIN_PASSWORD_RESET_DONE');
+}
+
+// Solves a task by given id number
+function adminSolveTask ($id) {
+ // Update the task data
+ adminUpdateTaskData($id, 'status', 'SOLVED');
+}
+
+// Marks a given task as deleted
+function adminDeleteTask ($id) {
+ // Update the task data
+ adminUpdateTaskData($id, 'status', 'DELETED');
+}
+
+// Function to update task data
+function adminUpdateTaskData ($id, $row, $data) {
+ // Should be admin!
+ if (!isAdmin()) {
+ // Not an admin so redirect better
+ redirectToUrl('index.php');
+ } // END - if
+
+ // Is the id not set, then we need a backtrace here... :(
+ if ($id <= 0) {
+ // Initiate backtrace
+ debug_report_bug(sprintf("id is invalid: %s. row=%s, data=%s",
+ $id,
+ $row,
+ $data
+ ));
+ } // END - if
+
+ // Update the task
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `%s`='%s' WHERE `id`=%s LIMIT 1",
+ array($row, $data, bigintval($id)), __FUNCTION__, __LINE__);
+}
+
+// Checks wether if the admin menu has entries
+function ifAdminMenuHasEntries ($action) {
+ return (
+ ((
+ isset($GLOBALS['admin_menu_has_entries'][$action])
+ ) && (
+ $GLOBALS['admin_menu_has_entries'][$action] === true
+ )) || (
+ $action == 'login'
+ )
+ );
+}
+
+// Setter for 'admin_menu_has_entries'
+function setAdminMenuHasEntries ($action, $hasEntries) {
+ $GLOBALS['admin_menu_has_entries'][$action] = (bool) $hasEntries;
+}
+
+// Creates a link to the user's admin-profile
+function adminCreateUserLink ($userid) {
+ // Is the userid set correctly?
+ if ($userid > 0) {
+ // Create a link to that profile
+ return '{?URL?}/modules.php?module=admin&what=list_user&userid='.bigintval($userid);
+ } // END - if
+
+ // Return a link to the user list
+ return '{?URL?}/modules.php?module=admin&what=list_user';
+}
+
+// Generate a "link" for the given admin id (admin_id)
+function generateAdminLink ($adminId) {
+ // No assigned admin is default
+ $adminLink = "<span class=\"admin_note\">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>";
+
+ // Zero? = Not assigned
+ if (bigintval($adminId) > 0) {
+ // Load admin's login
+ $login = getAdminLogin($adminId);
+
+ // Is the login valid?
+ if ($login != '***') {
+ // Is the extension there?
+ if (isExtensionActive('admins')) {
+ // Admin found
+ $adminLink = "<a href=\"".generateEmailLink(getAdminEmail($adminId), 'admins')."\">" . $login."</a>";
+ } else {
+ // Extension not found
+ $adminLink = sprintf(getMessage('EXTENSION_PROBLEM_NOT_INSTALLED'), 'admins');
+ }
+ } else {
+ // Maybe deleted?
+ $adminLink = "<div class=\"admin_note\">".sprintf(getMessage('ADMIN_ID_404'), $adminId)."</div>";
+ }
+ } // END - if
+
+ // Return result
+ return $adminLink;
+}
+
+// [EOF]