diff --git a/groupsorg.module b/groupsorg.module
index aa8cb2c..949894f 100644
--- a/groupsorg.module
+++ b/groupsorg.module
@@ -98,6 +98,10 @@ function groupsorg_block($op = 'list', $delta = 0) {
'info' => 'Groups quick statistics',
'cache' => BLOCK_CACHE_GLOBAL,
);
+ $blocks['groupsorg_event_stats'] = array(
+ 'info' => 'Drupal events activity',
+ 'cache' => BLOCK_CACHE_GLOBAL,
+ );
return $blocks;
case 'view':
$function = $delta. '_block_view';
@@ -192,8 +196,6 @@ function groupsorg_menu() {
return $items;
}
-
-
/**
* @todo: move this to a block? Gain caching...
* @see groupsorg_init().
@@ -213,6 +215,38 @@ function groupsorg_stats_block_view() {
}
/**
+ * @todo: move this to a block? Gain caching...
+ * @see groupsorg_init().
+ */
+function groupsorg_event_stats_block_view() {
+ $sql = "SELECT COUNT(*) FROM {node} node
+ LEFT JOIN {content_type_event} event ON node.vid = event.vid
+ WHERE node.status=1 AND node.type IN ('event') AND FROM_UNIXTIME(event.field_start7_value, '%Y') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 YEAR), '%Y')";
+ $count = db_result(db_query($sql));
+ $block['content'] .= t('@events events in last year
', array('@events' => $count));
+
+ $sql = "SELECT COUNT(*) FROM {node} node
+ LEFT JOIN {content_type_event} event ON node.vid = event.vid
+ WHERE node.status=1 AND node.type IN ('event') AND FROM_UNIXTIME(event.field_start7_value, '%Y') = FROM_UNIXTIME(unix_timestamp(), '%Y')
+ AND field_event_type_value IN ('regional')";
+ $count = db_result(db_query($sql));
+ $block['content'] .= t('@events camps this year
', array('@events' => $count));
+
+ $date_from = strtotime('last Monday');
+ $date_to = strtotime('this Monday');
+ $count = db_result(db_query("SELECT COUNT(*) FROM {signup_log} signup_log WHERE signup_time >= %d AND signup_time < %d;", $date_from, $date_to));
+ $block['content'] .= t('@events events signup last week
', array('@events' => $count));
+
+ $sql = "SELECT COUNT(*) FROM {node} node
+ LEFT JOIN {content_type_event} event ON node.vid = event.vid
+ WHERE node.status=1 AND node.type IN ('event') AND FROM_UNIXTIME(event.field_start7_value, '%Y-%m') = DATE_FORMAT(DATE_ADD(NOW(), INTERVAL 1 MONTH), '%Y-%m')";
+ $count = db_result(db_query($sql));
+ $block['content'] .= t('@events events coming up next month
', array('@events' => $count));
+
+ return $block;
+}
+
+/**
* moshe wants it this way. most people should see our tower of babel.
*/
function groupsorg_cron() {
@@ -389,6 +423,8 @@ function groupsorg_sprites_images_ignore() {
* Implements hook_form_alter().
*/
function groupsorg_form_alter(&$form, $form_state, $form_id) {
+ global $user;
+
// For group admins on node forms that are a group type where they are editing an existing post, make the group selection box "big".
if ($form['#id'] == 'node-form' && $form_id == $form['type']['#value'] .'_node_form' && !empty($form['nid']['#value']) && user_access('administer organic groups') && og_is_group_post_type($form['type']['#value'])) {
if (isset($form['og_nodeapi']['visible'])) {
@@ -398,7 +434,6 @@ function groupsorg_form_alter(&$form, $form_state, $form_id) {
}
// Prevent users from signing up for nodes that require attendees' full name.
if ($form_id == 'signup_form') {
- global $user;
$account = user_load($user->uid);
$node = node_load($form['nid']['#value']);
if (strpos($node->body, '') !== FALSE && empty($account->profile_full_name)) {
@@ -412,6 +447,12 @@ function groupsorg_form_alter(&$form, $form_state, $form_id) {
);
}
}
+
+ // Hide checkboxes "Only my signups" and "Only events in my group" from anonymous users in the /events list
+ if ($form_id == 'views_exposed_form' && $form['#id'] == 'views-exposed-form-event-list-page-1' && $user->uid == 0) {
+ $form['uid']['#access'] = FALSE;
+ $form['signup_user_current']['#access'] = FALSE;
+ }
}
/**