Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Return some simple calculated stats
- */
- function samsungblog_helper_simplestats() {
- /* First, we want some user stats */
- $sql_totalusers = "select count(users.status) from users users where status = 1;";
- $totalusers = db_result(db_query($sql_totalusers));
- $output = "<h4>" . t("User stats") . "</h4>\n" ;
- /* This is a more optimised query */
- $sql_users = "select r.name, count(ur.uid) user_cnt from role r inner join users_roles ur on r.rid = ur.rid group by r.name;";
- $result_users = db_query($sql_users);
- $output .= "<ul>\n";
- while ($row = db_fetch_array($result_users)) {
- $output .= "<li>" . $row['user_cnt'] . " " . t("users has role ") . "<em>" . $row['name'] . "</em></li>\n";
- }
- $output .= "</ul>\n";
- $output .= "<p><span class='simpletotal'>" . $totalusers . "</span> " . t("total active users") . "</p>\n";
- $output .= "<br />";
- /* Now, some content stats */
- $output .= "<h4>" . t("Content stats") . "</h4>\n";
- $sql_nodes = "select type,count(nid) as total from node where status=1 group by type;";
- $result_nodes = db_query($sql_nodes);
- $total_nodes = 0;
- $output .= "<ul>\n";
- while ($row = db_fetch_array($result_nodes)) {
- $total_nodes = $total_nodes + $row['total'];
- $output .= "<li>" . $row['total'] . " " . t('published nodes of type ') . "<em>" . $row['type'] . "</em></li>\n";
- }
- $output .= "</ul>\n";
- $output .= "<p><span class='simpletotal'>" . $total_nodes . "</span> " . t("total published nodes") . "</p>\n";
- /* Return the content */
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement