1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
/** * Returns the Super Users email information. If you provide a comma separated $email list * we will check that these emails do belong to Super Users and that they have not blocked * system emails. * * @param null|string $email A list of Super Users to email * * @return array The list of Super User emails * * @since 3.5 */ private function getSuperUsers($email = null) { // Get a reference to the database object $db = JFactory::getDBO(); // Convert the email list to an array if (!empty($email)) { $temp = explode(',', $email); $emails = array(); foreach ($temp as $entry) { $entry = trim($entry); $emails[] = $db->q($entry); } $emails = array_unique($emails); } else { $emails = array(); } // Get a list of groups which have Super User privileges $ret = array(); try { $query = $db->getQuery(true) ->select($db->qn('rules')) ->from($db->qn('#__assets')) ->where($db->qn('parent_id') . ' = ' . $db->q(0)); $db->setQuery($query, 0, 1); $rulesJSON = $db->loadResult(); $rules = json_decode($rulesJSON, true); $rawGroups = $rules['core.admin']; $groups = array(); if (empty($rawGroups)) { return $ret; } foreach ($rawGroups as $g => $enabled) { if ($enabled) { $groups[] = $db->q($g); } } if (empty($groups)) { return $ret; } } catch (Exception $exc) { return $ret; } // Get the user IDs of users belonging to the SA groups try { $query = $db->getQuery(true) ->select($db->qn('user_id')) ->from($db->qn('#__user_usergroup_map')) ->where($db->qn('group_id') . ' IN(' . implode(',', $groups) . ')'); $db->setQuery($query); $rawUserIDs = $db->loadColumn(0); if (empty($rawUserIDs)) { return $ret; } $userIDs = array(); foreach ($rawUserIDs as $id) { $userIDs[] = $db->q($id); } } catch (Exception $exc) { return $ret; } // Get the user information for the Super Administrator users try { $query = $db->getQuery(true) ->select( array( $db->qn('id'), $db->qn('username'), $db->qn('email'), ) )->from($db->qn('#__users')) ->where($db->qn('id') . ' IN(' . implode(',', $userIDs) . ')') ->where($db->qn('sendEmail') . ' = ' . $db->q('1')); if (!empty($emails)) { $query->where($db->qn('email') . 'IN(' . implode(',', $emails) . ')'); } $db->setQuery($query); $ret = $db->loadObjectList(); } catch (Exception $exc) { return $ret; } return $ret; } |



