/**
  * Gets the formated user wall content.
  * Uses the configured template.
  *
  * @param string $user_login User login to retrieve the wall for.
  * @return string Formated wall content.
  */
 private function getUserWall($user_login)
 {
     if (empty($user_login)) {
         return false;
     }
     $user = get_userdatabylogin($user_login);
     if (!$user) {
         return false;
     }
     $wall_items = $this->getTheWall($user->ID);
     if (empty($wall_items)) {
         return false;
     }
     // 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('items', $wall_items);
     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: Page the wall activity.
     return $template->getDisplay('userwall-' . $this->getOption('user_template'), 'userwall-default');
 }
 /**
  * Display a User Profile page.
  *
  * @uses apply_filters() Calls the 'user_aim_label', 'user_yim_label' and 'user_jabber_label' hooks on their corresponding labels.
  * @uses apply_filters() Calls the 'aoc_profile_header' on an empty string with user object as an extra param.
  * @uses apply_filters() Calls the 'aoc_profile_footer' on an empty string with user object as an extra param.
  * @uses do_action() Calls the 'aoc_profile_data' to get user additional data.
  *
  * @param string $name	Login Name for the user.
  * @return string|false	The formated profile or false if the user cannot be shown.
  */
 private function userProfile($name)
 {
     global $wpdb;
     $user_login = sanitize_user($name);
     $out = '';
     if (empty($user_login)) {
         // No user name provided
         return false;
     }
     $user = get_userdatabylogin($user_login);
     if (!$user) {
         // User not found.
         return false;
     }
     if (!$this->canShowUser($user)) {
         return false;
     }
     // Load and process the page template.
     require_once AK_CLASSES . '/template.php';
     $template = new akTemplate(aoc_template_paths());
     $template->textDomain($this->PID);
     $template->assign('header', apply_filters('aoc_profile_header', '', $user));
     $template->assign('footer', apply_filters('aoc_profile_footer', '', $user));
     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/profile.php">' . __('Edit your profile', $this->PID) . '</a>';
         } elseif (current_user_can('edit_users')) {
             $link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/user-edit.php?user_id=' . $user->ID . '">' . __('Edit this user', $this->PID) . '</a>';
         }
         $template->assign('edit_link', $link);
     }
     if ($this->getOption('author_page')) {
         $template->assign('author_link', $this->authorPostsLink($user));
     }
     // Now, we set/unset the user data based on privacy settings.
     unset($user->user_pass);
     // Just for security do not provide the password to templates.
     // User full name.
     if ($this->getOption('show_firstname') && !empty($user->first_name)) {
         $user->aoc_full_name = $user->first_name;
         if ($this->getOption('show_lastname')) {
             $user->aoc_full_name .= ' ' . $user->last_name;
         }
         unset($user->first_name);
         unset($user->last_name);
         unset($user->user_firstname);
         unset($user->user_lastname);
     }
     // Translated Role
     $roles = ak_get_roles(true);
     $user->aoc_translated_role = $roles[ak_get_user_role($user)];
     $user->user_url = 'http://' == $user->user_url ? '' : $user->user_url;
     // Email and IM addresses
     if (!$this->getOption('show_email')) {
         unset($user->user_email);
     }
     if (!$this->getOption('show_aim')) {
         unset($user->aim);
     }
     if (!$this->getOption('show_yahoo')) {
         unset($user->yim);
     }
     if (!$this->getOption('show_jabber')) {
         unset($user->jabber);
     }
     // Pager links
     $template->assign('prev_link', $this->pageNavigator($user, 'prev'));
     $template->assign('next_link', $this->pageNavigator($user, 'next'));
     // Get user data from action hooks.
     $user->aoc_widgets = array();
     do_action('aoc_profile_data', $user);
     $template->assignByRef('user', $user);
     return $template->getDisplay('profile-' . $this->getOption('profile_template'), 'profile-default');
 }
 /**
  * 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);
 }