/** * getStats * * @param int $userid * * @return void */ function getStats($userid) { $data = array(); $postsCount = getPostsById($userid, 'array'); $photosCount = getPhotosById($userid, 'array'); $commentsCount = getCommentsById($userid, 'array'); $calendarsCount = getCalendarEntriesById($userid, 'array'); $data['posts'] = ' <div class="stat" data-percent="' . $postsCount['percent'] . '"> <div class="label">' . T_('Posts') . '</div> <span class="inner" title="' . $postsCount['percent'] . '%">' . $postsCount['count'] . '</span> </div>'; $data['photos'] = ' <div class="stat" data-percent="' . $photosCount['percent'] . '"> <div class="label">' . T_('Photos') . '</div> <span class="inner" title="' . $photosCount['percent'] . '%">' . $photosCount['count'] . '</span> </div>'; $data['comments'] = ' <div class="stat" data-percent="' . $commentsCount['percent'] . '"> <div class="label">' . T_('Comments') . '</div> <span class="inner" title="' . $commentsCount['percent'] . '%">' . $commentsCount['count'] . '</span> </div>'; $data['events'] = ' <div class="stat" data-percent="' . $calendarsCount['percent'] . '"> <div class="label">' . T_('Dates') . '</div> <span class="inner" title="' . $calendarsCount['percent'] . '%">' . $calendarsCount['count'] . '</span> </div>'; if (usingFamilyNews()) { $newsCount = getFamilyNewsById($userid, 'array'); $data['news'] = ' <div class="stat" data-percent="' . $newsCount['percent'] . '"> <div class="label">' . T_('Family News') . '</div> <span class="inner" title="' . $newsCount['percent'] . '%">' . $newsCount['count'] . '</span> </div>'; } if (usingRecipes()) { $recipesCount = getRecipesById($userid, 'array'); $data['recipes'] = ' <div class="stat" data-percent="' . $recipesCount['percent'] . '"> <div class="label">' . T_('Recipes') . '</div> <span class="inner" title="' . $recipesCount['percent'] . '%">' . $recipesCount['count'] . '</span> </div>'; } if (usingDocuments()) { $documentsCount = getDocumentsById($userid, 'array'); $data['documents'] = ' <div class="stat" data-percent="' . $documentsCount['percent'] . '"> <div class="label">' . T_('Documents') . '</div> <span class="inner" title="' . $documentsCount['percent'] . '%">' . $documentsCount['count'] . '</span> </div>'; } if (usingPrayers()) { $prayersCount = getPrayersById($userid, 'array'); $data['prayers'] = ' <div class="stat" data-percent="' . $prayersCount['percent'] . '"> <div class="label">' . T_('Prayer Concerns') . '</div> <span class="inner" title="' . $prayersCount['percent'] . '%">' . $prayersCount['count'] . '</span> </div>'; } return $data; }
/** * getUserParticipationPoints * * Get the participation points for the given member. * * Action Points * ------------------- * thread 5 * photo 3 * news 3 * recipe 2 * document 2 * prayer 2 * post 2 * comment 2 * address 1 * phone # 1 * date/event 1 * vote 1 * * @param int $id * @return int */ function getUserParticipationPoints($id) { $fcmsError = FCMS_Error::getInstance(); $fcmsDatabase = Database::getInstance($fcmsError); $id = (int) $id; $points = 0; $commentTables = array('fcms_gallery_photo_comment'); // Thread (5) $sql = "SELECT COUNT(`id`) AS thread\n FROM `fcms_board_threads`\n WHERE `started_by` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } $points += $r['thread'] * 5; // Photo (3) $sql = "SELECT COUNT(`id`) AS photo \n FROM `fcms_gallery_photos` \n WHERE `user` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } $points += $r['photo'] * 3; // News (3) if (usingFamilyNews()) { array_push($commentTables, 'fcms_news_comments'); $sql = "SELECT COUNT(`id`) AS news \n FROM `fcms_news` \n WHERE `user` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } $points += $r['news'] * 3; } // Recipe (2) if (usingRecipes()) { array_push($commentTables, 'fcms_recipe_comment'); $sql = "SELECT COUNT(`id`) AS recipe \n FROM `fcms_recipes` \n WHERE `user` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } $points += $r['recipe'] * 2; } // Document (2) if (usingDocuments()) { $sql = "SELECT COUNT(`id`) AS doc \n FROM `fcms_documents` \n WHERE `user` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } $points += $r['doc'] * 2; } // Prayer (2) if (usingPrayers()) { $sql = "SELECT COUNT(`id`) AS prayer \n FROM `fcms_prayers` \n WHERE `user` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } $points += $r['prayer'] * 2; } // Post (2) $sql = "SELECT COUNT(`id`) AS post \n FROM `fcms_board_posts` \n WHERE `user` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } $points += $r['post'] * 2; // Comment (2) $from = implode('`, `', $commentTables); $where = implode("`.`user` = '{$id}' AND `", $commentTables); $sql = "SELECT COUNT(*) AS comment \n FROM `{$from}` \n WHERE `{$where}`.`user` = '{$id}'"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } $points += $r['comment'] * 2; // Address/Phone (1) $sql = "SELECT `address`, `city`, `state`, `home`, `work`, `cell` \n FROM `fcms_address` \n WHERE `user` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } if (!empty($r['address']) && !empty($r['city']) && !empty($r['state'])) { $points++; } if (!empty($r['home'])) { $points++; } if (!empty($r['work'])) { $points++; } if (!empty($r['cell'])) { $points++; } // Date/Event $sql = "SELECT COUNT(`id`) AS event \n FROM `fcms_calendar` \n WHERE `created_by` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } $points += $r['event']; // Vote $sql = "SELECT COUNT(`id`) AS vote \n FROM `fcms_poll_votes` \n WHERE `user` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return 0; } $points += $r['vote']; return $points; }