diff options
Diffstat (limited to 'modules/gallery/libraries')
| -rw-r--r-- | modules/gallery/libraries/Admin_View.php | 16 | ||||
| -rw-r--r-- | modules/gallery/libraries/Gallery_View.php | 22 | ||||
| -rw-r--r-- | modules/gallery/libraries/IdentityProvider.php | 209 | ||||
| -rw-r--r-- | modules/gallery/libraries/InPlaceEdit.php | 88 | ||||
| -rw-r--r-- | modules/gallery/libraries/Menu.php | 90 | ||||
| -rw-r--r-- | modules/gallery/libraries/Theme_View.php | 103 | ||||
| -rw-r--r-- | modules/gallery/libraries/drivers/IdentityProvider.php | 133 | 
7 files changed, 554 insertions, 107 deletions
| diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index 21b70df6..cbb781a1 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -27,29 +27,27 @@ class Admin_View_Core extends Gallery_View {     * @return  void     */    public function __construct($name) { -    $theme_name = module::get_var("gallery", "active_site_theme"); -    if (!file_exists("themes/$theme_name")) { -      module::set_var("gallery", "active_site_theme", "admin_default"); +    $theme_name = module::get_var("gallery", "active_admin_theme"); +    if (!file_exists(THEMEPATH . $theme_name)) { +      module::set_var("gallery", "active_admin_theme", "admin_wind");        theme::load_themes();        Kohana::log("error", "Unable to locate theme '$theme_name', switching to default theme.");      }      parent::__construct($name);      $this->theme_name = module::get_var("gallery", "active_admin_theme"); -    if (user::active()->admin) { +    if (identity::active_user()->admin) {        $this->theme_name = Input::instance()->get("theme", $this->theme_name);      }      $this->sidebar = "";      $this->set_global("theme", $this); -    $this->set_global("user", user::active()); +    $this->set_global("user", identity::active_user());    }    public function admin_menu() {      $menu = Menu::factory("root"); -    gallery::admin_menu($menu, $this);      module::event("admin_menu", $menu, $this); -    $menu->compact(); -    return $menu; +    return $menu->render();    }    /** @@ -97,7 +95,7 @@ class Admin_View_Core extends Gallery_View {        if (Session::instance()->get("debug")) {          if ($function != "admin_head") {            array_unshift( -            $blocks, "<div class=\"gAnnotatedThemeBlock gAnnotatedThemeBlock_$function\">" . +            $blocks, "<div class=\"g-annotated-theme-block g-annotated-theme-block_$function\">" .              "<div class=\"title\">$function</div>");            $blocks[] = "</div>";          } diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php index 219cc883..bdfd2fc9 100644 --- a/modules/gallery/libraries/Gallery_View.php +++ b/modules/gallery/libraries/Gallery_View.php @@ -24,12 +24,12 @@ class Gallery_View_Core extends View {    /**     * Add a script to the combined scripts list. -   * @param $file  the relative path to a script from the gallery3 directory +   * @param $file  the file name or path of the script to include. If a path is specified then +   *               it needs to be relative to DOCROOT. Just specifying a file name will result +   *               in searching Kohana's cascading file system.     */    public function script($file) { -    $base_file = str_replace(".js", "", $file); -    if (($path = Kohana::find_file("js", $base_file, false, "js")) || -        file_exists($path = DOCROOT . "lib/$file")) { +    if (($path = gallery::find_file("js", $file, false))) {        $this->scripts[$path] = 1;      } else {        Kohana::log("error", "Can't find script file: $file"); @@ -47,12 +47,12 @@ class Gallery_View_Core extends View {    /**     * Add a css file to the combined css list. -   * @param $file  the relative path to a script from the gallery3 directory +   * @param $file  the file name or path of the script to include. If a path is specified then +   *               it needs to be relative to DOCROOT. Just specifying a file name will result +   *               in searching Kohana's cascading file system.     */    public function css($file) { -    $base_file = str_replace(".css", "", $file); -    if (($path = Kohana::find_file("css", $base_file, false, "css")) || -        file_exists($path = DOCROOT . "lib/$file")) { +    if (($path = gallery::find_file("css", $file, false))) {        $this->css[$path] = 1;      } else {        Kohana::log("error", "Can't find css file: $file"); @@ -85,13 +85,11 @@ class Gallery_View_Core extends View {      if (empty($contents)) {        $contents = ""; -      $docroot_len = strlen(DOCROOT);        foreach (array_keys($paths) as $path) { -        $relative = substr($path, $docroot_len);          if ($type == "css") { -          $contents .= "/* $relative */\n" . $this->process_css($path) . "\n"; +          $contents .= "/* $path */\n" . $this->process_css($path) . "\n";          } else { -          $contents .= "/* $relative */\n" . file_get_contents($path) . "\n"; +          $contents .= "/* $path */\n" . file_get_contents($path) . "\n";          }        } diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php new file mode 100644 index 00000000..e213ae97 --- /dev/null +++ b/modules/gallery/libraries/IdentityProvider.php @@ -0,0 +1,209 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA. + */ + +/** + * Provides a driver-based interface for managing users and groups. + */ +class IdentityProvider_Core { +  protected static $instance; + +  // Configuration +  protected $config; + +  // Driver object +  protected $driver; + +  /** +   * Returns a singleton instance of Identity. +   * There can only be one Identity driver configured at a given point +   * +   * @param   string  configuration +   * @return  Identity_Core +   */ +  static function &instance() { +   if (empty(self::$instance)) { +      // Create a new instance +      self::$instance = new IdentityProvider(); +    } + +    return self::$instance; +  } + +  /** +   * Frees the current instance of the identity provider so the next call to instance will reload +   * +   * @param   string  configuration +   * @return  Identity_Core +   */ +  static function reset() { +    self::$instance = null; +    Kohana::config_clear("identity"); +  } + +  /** +   * Loads the configured driver and validates it. +   * +   * @return  void +   */ +  public function __construct($config=null) { +    if (empty($config)) { +      $config = module::get_var("gallery", "identity_provider", "user"); +    } + +    // Test the config group name +    if (($this->config = Kohana::config("identity." . $config)) === NULL) { +      throw new Exception("@todo NO_USER_LIBRARY_CONFIGURATION_FOR: $config"); +    } + +    // Set driver name +    $driver = "IdentityProvider_" . ucfirst($this->config["driver"])  ."_Driver"; + +    // Load the driver +    if ( ! Kohana::auto_load($driver)) { +      throw new Kohana_Exception("core.driver_not_found", $this->config["driver"], +                                 get_class($this)); +    } + +    // Initialize the driver +    $this->driver = new $driver($this->config["params"]); + +    // Validate the driver +    if ( !($this->driver instanceof IdentityProvider_Driver)) { +      throw new Kohana_Exception("core.driver_implements", $this->config["driver"], +                                 get_class($this), "IdentityProvider_Driver"); +    } + +    Kohana::log("debug", "Identity Library initialized"); +  } + +  /** +   * Determine if if the current driver supports updates. +   * +   * @return boolean true if the driver supports updates; false if read only +   */ +  public function is_writable() { +    return !empty($this->config["allow_updates"]); +  } + +  /** +   * @see IdentityProvider_Driver::guest. +   */ +  public function guest() { +    return $this->driver->guest(); +  } + +  /** +   * @see IdentityProvider_Driver::admin_user. +   */ +  public function admin_user() { +    return $this->driver->admin_user(); +  } + +  /** +   * @see IdentityProvider_Driver::create_user. +   */ +  public function create_user($name, $full_name, $password) { +    return $this->driver->create_user($name, $full_name, $password); +  } + +  /** +   * @see IdentityProvider_Driver::is_correct_password. +   */ +  public function is_correct_password($user, $password) { +    return $this->driver->is_correct_password($user, $password); +  } + +  /** +   * @see IdentityProvider_Driver::lookup_user. +   */ +  public function lookup_user($id) { +    return $this->driver->lookup_user($id); +  } + +  /** +   * @see IdentityProvider_Driver::lookup_user_by_name. +   */ +  public function lookup_user_by_name($name) { +    return $this->driver->lookup_user_by_name($name); +  } + +  /** +   * @see IdentityProvider_Driver::create_group. +   */ +  public function create_group($name) { +    return $this->driver->create_group($name); +  } + +  /** +   * @see IdentityProvider_Driver::everybody. +   */ +  public function everybody() { +    return $this->driver->everybody(); +  } + +  /** +   * @see IdentityProvider_Driver::registered_users. +   */ +  public function registered_users() { +    return $this->driver->registered_users(); +  } + +  /** +   * @see IdentityProvider_Driver::lookup_group. +   */ +  public function lookup_group($id) { +    return $this->driver->lookup_group($id); +  } + +  /** +   * @see IdentityProvider_Driver::lookup_group_by_name. +   */ +  public function lookup_group_by_name($name) { +    return $this->driver->lookup_group_by_name($name); +  } + +  /** +   * @see IdentityProvider_Driver::get_user_list. +   */ +  public function get_user_list($ids) { +    return $this->driver->get_user_list($ids); +  } + +  /** +   * @see IdentityProvider_Driver::groups. +   */ +  public function groups() { +    return $this->driver->groups(); +  } + +  /** +   * @see IdentityProvider_Driver::add_user_to_group. +   */ +  public function add_user_to_group($user, $group_id) { +    return $this->driver->add_user_to_group($user, $group_id); +  } + +  /** +   * @see IdentityProvider_Driver::remove_user_to_group. +   */ +  public function remove_user_from_group($user, $group_id) { +    return $this->driver->remove_user_from_group($user, $group_id); +  } +} // End Identity diff --git a/modules/gallery/libraries/InPlaceEdit.php b/modules/gallery/libraries/InPlaceEdit.php new file mode 100644 index 00000000..67ab3805 --- /dev/null +++ b/modules/gallery/libraries/InPlaceEdit.php @@ -0,0 +1,88 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA. + */ +class InPlaceEdit_Core { +  private $rules = array(); +  private $messages = array(); +  private $callback = array(); +  private $initial_value; +  private $action = ""; +  private $errors; +  private $form; + +  static function factory($initial_value) { +    $instance = new InPlaceEdit(); +    $instance->initial_value = $initial_value; +    $instance->form = array("input" => $initial_value); +    $instance->errors = array("input" => ""); + +    return $instance; +  } + +  public function action($action) { +    $this->action = $action; +    return $this; +  } + +  public function rules($rules) { +    $this->rules += $rules; +    return $this; +  } + +  public function messages($messages) { +    $this->messages += $messages; +    return $this; +  } + +  public function callback($callback) { +    $this->callback = $callback; +    return $this; +  } + +  public function validate() { +    $post = Validation::factory($_POST) +      ->add_callbacks("input", $this->callback); +    foreach ($this->rules as $rule) { +      $post->add_rules("input", $rule); +    } + +    $valid = $post->validate(); +    $this->form = array_merge($this->form, $post->as_array()); +    $this->errors = array_merge($this->errors, $post->errors()); +    return $valid; +  } + +  public function render() { +    $v = new View("in_place_edit.html"); +    $v->hidden = array("csrf" => access::csrf_token()); +    $v->action = url::site($this->action); +    $v->form = $this->form; +    $v->errors = $this->errors; +    foreach ($v->errors as $key => $error) { +      if (!empty($error)) { +        $v->errors[$key] = $this->messages[$error]; +      } +    } +    return $v->render(); +  } + +  public function value() { +    return $this->form["input"]; +  } +}
\ No newline at end of file diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 07b2b2b8..e2b68d1a 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -43,6 +43,11 @@ class Menu_Element {     * @chainable     */    public function label($label) { +    // Guard against developers who forget to internationalize label strings +    if (!($label instanceof SafeString)) { +      $label = new SafeString($label); +    } +      $this->label = $label;      return $this;    } @@ -74,25 +79,25 @@ class Menu_Element {      return $this;    } +  /** +   * Specifiy a view for this menu item +   * @chainable +   */ +  public function view($view) { +    $this->view = $view; +    return $this; +  } +  }  /**   * Menu element that provides a link to a new page.   */  class Menu_Element_Link extends Menu_Element { -  public function __toString() { -    if (isset($this->css_id) && !empty($this->css_id)) { -      $css_id = " id=\"$this->css_id\""; -    } else { -      $css_id = ""; -    } -    if (isset($this->css_class) && !empty($this->css_class)) { -      $css_class = " $this->css_class"; -    } else { -      $css_class = ""; -    } -    return "<li><a$css_id class=\"gMenuLink $css_class\" href=\"$this->url\" " . -      "title=\"$this->label\">$this->label</a></li>"; +  public function render() { +    $view = new View(isset($this->view) ? $this->view : "menu_link.html"); +    $view->menu = $this; +    return $view;    }  } @@ -111,19 +116,10 @@ class Menu_Element_Ajax_Link extends Menu_Element {      return $this;    } -  public function __toString() { -    if (isset($this->css_id) && !empty($this->css_id)) { -      $css_id = " id=\"$this->css_id\""; -    } else { -      $css_id = ""; -    } -    if (isset($this->css_class) && !empty($this->css_class)) { -      $css_class = " $this->css_class"; -    } else { -      $css_class = ""; -    } -    return "<li><a$css_id class=\"gAjaxLink $css_class\" href=\"$this->url\" " . -      "title=\"$this->label\" ajax_handler=\"$this->ajax_handler\">$this->label</a></li>"; +  public function render() { +    $view = new View(isset($this->view) ? $this->view : "menu_ajax_link.html"); +    $view->menu = $this; +    return $view;    }  } @@ -131,19 +127,10 @@ class Menu_Element_Ajax_Link extends Menu_Element {   * Menu element that provides a pop-up dialog   */  class Menu_Element_Dialog extends Menu_Element { -  public function __toString() { -    if (isset($this->css_id) && !empty($this->css_id)) { -      $css_id = " id=\"$this->css_id\""; -    } else { -      $css_id = ""; -    } -    if (isset($this->css_class) && !empty($this->css_class)) { -      $css_class = " $this->css_class"; -    } else { -      $css_class = ""; -    } -    return "<li><a$css_id class=\"gDialogLink $css_class\" href=\"$this->url\" " . -           "title=\"$this->label\">$this->label</a></li>"; +  public function render() { +    $view = new View(isset($this->view) ? $this->view : "menu_dialog.html"); +    $view->menu = $this; +    return $view;    }  } @@ -171,7 +158,7 @@ class Menu_Core extends Menu_Element {      case "root":        $menu = new Menu("root"); -      $menu->css_class("gMenu"); +      $menu->css_class("g-menu");        return $menu;      case "submenu": @@ -182,19 +169,6 @@ class Menu_Core extends Menu_Element {      }    } -  public function compact() { -    foreach ($this->elements as $target_id => $element) { -      if ($element->type == "submenu") { -        if (empty($element->elements)) { -          $this->remove($target_id); -        } else { -          $element->compact(); -        } -      } -    } -    return $this; -  } -    public function __construct($type) {      parent::__construct($type);      $this->elements = array(); @@ -242,11 +216,9 @@ class Menu_Core extends Menu_Element {      return null;    } -  public function __toString() { -    $html = $this->is_root ? "<ul class=\"$this->css_class\">" : -      "<li title=\"$this->label\"><a href=\"#\">$this->label</a><ul>"; -    $html .= implode("\n", $this->elements); -    $html .= $this->is_root ? "</ul>" : "</ul></li>"; -    return $html; +  public function render() { +    $view = new View(isset($this->view) ? $this->view : "menu.html"); +    $view->menu = $this; +    return $view;    }  } diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 130e2dce..e98914c4 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -29,21 +29,21 @@ class Theme_View_Core extends Gallery_View {     */    public function __construct($name, $page_type) {      $theme_name = module::get_var("gallery", "active_site_theme"); -    if (!file_exists("themes/$theme_name")) { -      module::set_var("gallery", "active_site_theme", "default"); +    if (!file_exists(THEMEPATH . $theme_name)) { +      module::set_var("gallery", "active_site_theme", "wind");        theme::load_themes();        Kohana::log("error", "Unable to locate theme '$theme_name', switching to default theme.");      }      parent::__construct($name);      $this->theme_name = module::get_var("gallery", "active_site_theme"); -    if (user::active()->admin) { +    if (identity::active_user()->admin) {        $this->theme_name = Input::instance()->get("theme", $this->theme_name);      }      $this->item = null;      $this->tag = null;      $this->set_global("theme", $this); -    $this->set_global("user", user::active()); +    $this->set_global("user", identity::active_user());      $this->set_global("page_type", $page_type);      $this->set_global("page_title", null);      if ($page_type == "album") { @@ -78,23 +78,30 @@ class Theme_View_Core extends Gallery_View {      return $this->page_type;    } +  public function user_menu() { +    $menu = Menu::factory("root") +      ->css_id("g-login-menu") +      ->css_class("g-inline ui-helper-clear-fix"); +    module::event("user_menu", $menu, $this); +    return $menu->render(); +  } +    public function site_menu() {      $menu = Menu::factory("root"); -    gallery::site_menu($menu, $this);      module::event("site_menu", $menu, $this); -    return $menu->compact(); +    return $menu->render();    }    public function album_menu() {      $menu = Menu::factory("root");      module::event("album_menu", $menu, $this); -    return $menu->compact(); +    return $menu->render();    }    public function tag_menu() {      $menu = Menu::factory("root");      module::event("tag_menu", $menu, $this); -    return $menu->compact(); +    return $menu->render();    }    public function photo_menu() { @@ -104,17 +111,17 @@ class Theme_View_Core extends Gallery_View {                      ->id("fullsize")                      ->label(t("View full size"))                      ->url($this->item()->file_url()) -                    ->css_class("gFullSizeLink")); +                    ->css_class("g-fullsize-link"));      }      module::event("photo_menu", $menu, $this); -    return $menu->compact(); +    return $menu->render();    }    public function movie_menu() {      $menu = Menu::factory("root");      module::event("movie_menu", $menu, $this); -    return $menu->compact(); +    return $menu->render();    }    public function context_menu($item, $thumbnail_css_selector) { @@ -122,23 +129,55 @@ class Theme_View_Core extends Gallery_View {        ->append(Menu::factory("submenu")                 ->id("context_menu")                 ->label(t("Options"))) -      ->css_class("gContextMenu"); +      ->css_class("g-context-menu"); -    gallery::context_menu($menu, $this, $item, $thumbnail_css_selector);      module::event("context_menu", $menu, $this, $item, $thumbnail_css_selector); -    return $menu->compact(); -  } - -  public function pager() { -    if ($this->children_count) { -      $this->pagination = new Pagination(); -      $this->pagination->initialize( -        array("query_string" => "page", -              "total_items" => $this->children_count, -              "items_per_page" => $this->page_size, -              "style" => "classic")); -      return $this->pagination->render(); +    return $menu->render(); +  } + +  /** +   * Set up the data and render a pager. +   * +   * See themes/wind/views/pager.html for documentation on the variables generated here. +   */ +  public function paginator() { +    $v = new View("paginator.html"); +    $v->page_type = $this->page_type; +    $v->first_page_url = null; +    $v->previous_page_url = null; +    $v->next_page_url = null; +    $v->last_page_url = null; + +    if ($this->page_type == "album" || $this->page_type == "tag") { +      $v->page = $this->page; +      $v->max_pages = $this->max_pages; +      $v->total = $this->children_count; + +      if ($this->page != 1) { +        $v->first_page_url = url::site(url::merge(array("page" => 1))); +        $v->previous_page_url = url::site(url::merge(array("page" => $this->page - 1))); +      } + +      if ($this->page != $this->max_pages) { +        $v->next_page_url = url::site(url::merge(array("page" => $this->page + 1))); +        $v->last_page_url = url::site(url::merge(array("page" => $this->max_pages))); +      } + +      $v->first_visible_position = ($this->page - 1) * $this->page_size + 1; +      $v->last_visible_position = $this->page * $this->page_size; +    } else { +      $v->position = $this->position; +      $v->total = $this->sibling_count; +      if ($this->previous_item) { +        $v->previous_page_url = $this->previous_item->url(); +      } + +      if ($this->next_item) { +        $v->next_page_url = $this->next_item->url(); +      }      } + +    return $v;    }    /** @@ -156,6 +195,17 @@ class Theme_View_Core extends Gallery_View {    }    /** +   * Print out the sidebar. +   */ +  public function sidebar_blocks() { +    $sidebar = block_manager::get_html("site_sidebar", $this); +    if (empty($sidebar) && identity::active_user()->admin) { +      $sidebar = new View("no_sidebar.html"); +    } +    return $sidebar; +  } + +  /**     * Handle all theme functions that insert module content.     */    public function __call($function, $args) { @@ -178,7 +228,6 @@ class Theme_View_Core extends Gallery_View {      case "photo_top":      case "resize_bottom":      case "resize_top": -    case "sidebar_blocks":      case "sidebar_bottom":      case "sidebar_top":      case "thumb_bottom": @@ -223,7 +272,7 @@ class Theme_View_Core extends Gallery_View {        if (Session::instance()->get("debug")) {          if ($function != "head") {            array_unshift( -            $blocks, "<div class=\"gAnnotatedThemeBlock gAnnotatedThemeBlock_$function gClearFix\">" . +            $blocks, "<div class=\"g-annotated-theme-block g-annotated-theme-block_$function g-clear-fix\">" .              "<div class=\"title\">$function</div>");            $blocks[] = "</div>";          } diff --git a/modules/gallery/libraries/drivers/IdentityProvider.php b/modules/gallery/libraries/drivers/IdentityProvider.php new file mode 100644 index 00000000..a808c7e8 --- /dev/null +++ b/modules/gallery/libraries/drivers/IdentityProvider.php @@ -0,0 +1,133 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2009 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA. + */ +interface IdentityProvider_Driver { +  /** +   * Return the guest user. +   * +   * @return User_Definition the user object +   */ +  public function guest(); + +  /** +   * Return the admins user. +   * +   * @return User_Definition the user object +   */ +  public function admin_user(); + +  /** +   * Create a new user. +   * +   * @param string  $name +   * @param string  $full_name +   * @param string  $password +   * @return User_Definition the user object +   */ +  public function create_user($name, $full_name, $password); + +  /** +   * Is the password provided correct? +   * +   * @param user User_Definition the user object +   * @param string $password a plaintext password +   * @return boolean true if the password is correct +   */ +  public function is_correct_password($user, $password); + +  /** +   * Look up a user by id. +   * @param integer $id +   * @return User_Definition the user object, or null if the name was invalid. +   */ +  public function lookup_user($id); + +  /** +   * Look up a user by name. +   * @param string $name +   * @return User_Definition the user object, or null if the name was invalid. +   */ +  public function lookup_user_by_name($name); + +  /** +   * Create a new group. +   * +   * @param string $name +   * @return Group_Definition the group object +   */ +  public function create_group($name); + +  /** +   * The group of all possible visitors.  This includes the guest user. +   * +   * @return Group_Definition the group object +   */ +  public function everybody(); + +  /** +   * The group of all logged-in visitors.  This does not include guest users. +   * +   * @return Group_Definition the group object +   */ +  public function registered_users(); + +  /** +   * List the users +   * @param array $ids array of ids to return the user objects for +   * @return array the user list. +   */ +  public function get_user_list($ids); + +  /** +   * Look up a group by id. +   * @param integer $id id +   * @return Group_Definition the user object, or null if the name was invalid. +   */ +  public function lookup_group($id); + +  /** +   * Look up the group by name. +   * @param string $name the name of the group to locate +   * @return Group_Definition +   */ +  public function lookup_group_by_name($name); + +  /** +   * List the groups defined in the Identity Provider +   */ +  public function groups(); + +  /** +   * Add the user to the specified group +   * @param User_Definition the user to add to the group +   * @param int             the group_id +   */ +  static function add_user_to_group($user, $group_id); + +  /** +   * Remove the user to the specified group +   * @param User_Definition the user to add to the group +   * @param int             the group id +   */ +  static function remove_user_from_group($user, $group_id); +} // End Identity Driver Definition + +interface Group_Definition {} + +interface User_Definition {} | 
