/**
  * Returns a list of arrays for activity items.
  * Each array will contain:
  * 		- avatar: The user avatar url.
  * 		- display: Text to display (with anchors to items)
  * 		- date: the event date.
  * @param $owner_id	User id to get the activity from. If 0, will return flobal activity.
  * @return array List of activity items
  */
 public function getTheWall($owner_id = 0)
 {
     global $wpdb;
     if (0 != $owner_id && !aoc_can_show_user($owner_id)) {
         return array();
     }
     $where = 0 == $owner_id ? '' : "WHERE `owner_id` = '{$owner_id}'";
     $q = "SELECT * FROM {$wpdb->aoc_activity} {$where} ORDER BY `event_date` DESC LIMIT 0,{$this->getOption('list_items')}";
     $wall_data = $wpdb->get_results($q, 'ARRAY_A');
     if (empty($wall_data)) {
         return array();
     }
     $wall_items = array();
     foreach ($wall_data as $item) {
         $display = $this->getHookDisplay($item);
         if ($display) {
             $wall_items[] = array('avatar' => get_avatar($item['owner_id'], $this->getOption('avatar_size')), 'date' => $item['event_date'], 'text' => $display);
         }
     }
     return $wall_items;
 }
 /**
  * Returns a User Gallery page.
  *
  * @uses apply_filters() Calls the 'aoc_gallery_page' hook on the function return value.
  * @param string $user_login_or_id Login Name or ID for the user.
  * @return string|false	The formated user gallery or false if the gallery cannot be shown.
  */
 public function userGalleryContent($user_login_or_id)
 {
     global $wpdb;
     if (empty($user_login_or_id)) {
         return false;
     }
     if (is_numeric($user_login_or_id)) {
         $user_login_or_id = intval($user_login_or_id);
         $user = get_userdata($user_login_or_id);
     } else {
         $user_login_or_id = sanitize_user($user_login_or_id);
         $user = get_userdatabylogin($user_login_or_id);
     }
     if (!$user) {
         // User not found.
         return false;
     }
     // Check if user has one role allowed to display
     if (!aoc_can_show_user($user)) {
         return false;
     }
     // Get the gallery images. If no images, return false.
     $images = $this->userGalleryLinks($user->ID);
     if (empty($images)) {
         return false;
     }
     unset($user->user_pass);
     // Security reasons.
     // Load and process the page template.
     require_once AK_CLASSES . '/template.php';
     $template = new akTemplate(aoc_template_paths());
     $template->textDomain($this->PID);
     $template->assignByRef('user', $user);
     $template->assign('images', $images);
     if (is_user_logged_in()) {
         $cur_user = wp_get_current_user();
         if ($cur_user->user_login == $user->user_login) {
             $link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/users.php?page=' . $this->slug . '-my-gallery">' . __('Manage your photo gallery', $this->PID) . '</a>';
         } elseif (current_user_can('aoc_manage_galleries')) {
             $link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/users.php?user_id=' . $user->ID . '&amp;page=' . $this->slug . '-my-gallery">' . __('Manage this user gallery', $this->PID) . '</a>';
         }
         $template->assign('edit_link', $link);
     }
     // TODO: If there are to much images, page the gallery.
     $out = $template->getDisplay('gallery-' . $this->getOption('gallery_template'), 'gallery-default');
     return apply_filters('aoc_gallery_page', $out);
 }