Dotclear


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.auth.php

    r333 r270  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2010 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1313 
    1414/** 
    15 * @ingroup DC_CORE 
    16 * @nosubgrouping 
    17 * @brief Authentication and user credentials management 
    18 *  
    19 * dcAuth is a class used to handle everything related to user authentication 
    20 * and credentials. Object is provided by dcCore $auth property. 
     15@ingroup DC_CORE 
     16@nosubgrouping 
     17@brief Authentication and user credentials management 
     18 
     19dcAuth is a class used to handle everything related to user authentication 
     20and credentials. Object is provided by dcCore $auth property. 
    2121*/ 
    2222class dcAuth 
    2323{ 
    24      /** @var dcCore dcCore instance */ 
    25      protected $core; 
    26      /** @var connection Database connection object */ 
    27      protected $con; 
    28       
    29      /** @var string User table name */ 
    30      protected $user_table; 
    31      /** @var string Perm table name */ 
    32      protected $perm_table; 
    33       
    34      /** @var string Current user ID */ 
    35      protected $user_id; 
    36      /** @var array Array with user information */ 
    37      protected $user_info = array(); 
    38      /** @var array Array with user options */ 
    39      protected $user_options = array(); 
    40      /** @var boolean User must change his password after login */ 
    41      protected $user_change_pwd; 
    42      /** @var boolean User is super admin */ 
    43      protected $user_admin; 
    44      /** @var array Permissions for each blog */ 
    45      protected $permissions = array(); 
    46      /** @var boolean User can change its password */ 
    47      protected $allow_pass_change = true; 
    48      /** @var array List of blogs on which the user has permissions */ 
    49      protected $blogs = array(); 
    50      /** @var integer Count of user blogs */ 
    51      public $blog_count = null; 
    52       
    53      /** @var array Permission types */ 
    54      protected $perm_types; 
    55       
    56      /** @var dcPrefs dcPrefs object */ 
    57      public $user_prefs; 
    58       
    59      /** 
    60      * Class constructor. Takes dcCore object as single argument. 
    61      *  
    62      * @param dcCore     $core          dcCore object 
     24     protected $core;         ///< <b>dcCore</b> dcCore instance 
     25     protected $con;          ///< <b>connection</b> Database connection object 
     26      
     27     protected $user_table;   ///< <b>string</b>  User table name 
     28     protected $perm_table;   ///< <b>string</b>  Perm table name 
     29      
     30     protected $user_id;                     ///< <b>string</b>       Current user ID 
     31     protected $user_info = array();         ///< <b>array</b>        Array with user information 
     32     protected $user_options = array();      ///< <b>array</b>        Array with user options 
     33     protected $user_change_pwd;             ///< <b>boolean</b>      User must change his password after login 
     34     protected $user_admin;                  ///< <b>boolean</b>      User is super admin 
     35     protected $permissions = array();       ///< <b>array</b>        Permissions for each blog 
     36     protected $allow_pass_change = true;    ///< <b>boolean</b>      User can change its password 
     37     protected $blogs = array();             ///< <b>array</b>        List of blogs on which the user has permissions 
     38     public $blog_count = null;                   ///< <b>integer</b>      Count of user blogs 
     39      
     40     protected $perm_types;   ///< <b>array</b> Permission types 
     41      
     42     public $user_prefs; ///< <b>dcPrefs</b> dcPrefs object 
     43      
     44     /** 
     45     Class constructor. Takes dcCore object as single argument. 
     46      
     47     @param    core      <b>dcCore</b>       dcCore object 
    6348     */ 
    6449     public function __construct($core) 
     
    8570     //@{ 
    8671     /** 
    87      * Checks if user exists and can log in. <var>$pwd</var> argument is optionnal 
    88      * while you may need to check user without password. This method will create 
    89      * credentials and populate all needed object properties. 
    90      *  
    91      * @param string     $user_id       User ID 
    92      * @param string     $pwd           User password 
    93      * @param string     $user_key      User key check 
    94      * @param boolean    $check_blog    checks if user is associated to a blog or not. 
    95      * @return boolean 
    96      */ 
    97      public function checkUser($user_id, $pwd=null, $user_key=null, $check_blog=true) 
     72     Checks if user exists and can log in. <var>$pwd</var> argument is optionnal 
     73     while you may need to check user without password. This method will create 
     74     credentials and populate all needed object properties. 
     75      
     76     @param    user_id   <b>string</b>       User ID 
     77     @param    pwd       <b>string</b>       User password 
     78     @param    user_key  <b>string</b>       User key check 
     79     @return   <b>boolean</b> 
     80     */ 
     81     public function checkUser($user_id, $pwd=null, $user_key=null) 
    9882     { 
    9983          # Check user and password 
     
    157141           
    158142          # Get permissions on blogs 
    159           if ($check_blog && ($this->findUserBlog() === false)) { 
     143          if ($this->findUserBlog() === false) { 
    160144               return false; 
    161145          } 
     
    164148      
    165149     /** 
    166      * This method only check current user password. 
    167      *  
    168      * @param string     $pwd           User password 
    169      * @return boolean 
     150     This method only check current user password. 
     151      
     152     @param    pwd       <b>string</b>       User password 
     153     @return   <b>boolean</b> 
    170154     */ 
    171155     public function checkPassword($pwd) 
     
    179163      
    180164     /** 
    181      * This method checks if user session cookie exists 
    182      *  
    183      * @return boolean 
     165     This method checks if user session cookie exists 
     166      
     167     @return   <b>boolean</b> 
    184168     */ 
    185169     public function sessionExists() 
     
    189173      
    190174     /** 
    191      * This method checks user session validity. 
    192      *  
    193      * @return boolean 
     175     This method checks user session validity. 
     176      
     177     @return   <b>boolean</b> 
    194178     */ 
    195179     public function checkSession($uid=null) 
     
    228212      
    229213     /** 
    230      * Checks if user is super admin 
    231      *  
    232      * @return boolean 
     214     Checks if user is super admin 
     215      
     216     @return   <b>boolean</b> 
    233217     */ 
    234218     public function isSuperAdmin() 
     
    238222      
    239223     /** 
    240      * Checks if user has permissions given in <var>$permissions</var> for blog 
    241      * <var>$blog_id</var>. <var>$permissions</var> is a coma separated list of 
    242      * permissions. 
    243      *  
    244      * @param string     $permissions   Permissions list 
    245      * @param string     $blog_id       Blog ID 
    246      * @return boolean 
     224     Checks if user has permissions given in <var>$permissions</var> for blog 
     225     <var>$blog_id</var>. <var>$permissions</var> is a coma separated list of 
     226     permissions. 
     227      
     228     @param    permissions    <b>string</b>       Permissions list 
     229     @param    blog_id        <b>string</b>       Blog ID 
     230     @return   <b>boolean</b> 
    247231     */ 
    248232     public function check($permissions,$blog_id) 
     
    273257      
    274258     /** 
    275      * Returns true if user is allowed to change its password. 
    276      *  
    277      * @return boolean 
     259     Returns true if user is allowed to change its password. 
     260      
     261     @return   <b>boolean</b> 
    278262     */ 
    279263     public function allowPassChange() 
     
    328312     //@{ 
    329313     /** 
    330      * Calls $f function with super admin rights. 
    331      * Returns the function result. 
    332      *  
    333      * @param callback   $f             Callback function 
    334      * @return mixed 
     314     Calls <var>$f</var> function with super admin rights. 
     315      
     316     @param    f         <b>callback</b>     Callback function 
     317     @return   <b>mixed</b> Function result 
    335318     */ 
    336319     public function sudo($f) 
     
    363346     //@{ 
    364347     /** 
    365      * Returns user permissions for a blog as an array which looks like: 
    366      *  
    367      *  - [blog_id] 
    368      *    - [permission] => true 
    369      *    - ... 
    370      *  
    371      * @param string     $blog_id       Blog ID 
    372      * @return array 
     348     Returns user permissions for a blog as an array which looks like: 
     349      
     350      - [blog_id] 
     351        - [permission] => true 
     352        - ... 
     353      
     354     @return   <b>array</b> 
    373355     */ 
    374356     public function getPermissions($blog_id) 
     
    440422      
    441423     /** 
    442      * Returns current user ID 
    443      *  
    444      * @return string 
     424     Returns current user ID 
     425      
     426     @return   <b>string</b> 
    445427     */ 
    446428     public function userID() 
     
    450432      
    451433     /** 
    452      * Returns information about a user . 
    453      *  
    454      * @param string     $n             Information name 
    455      * @return string 
     434     Returns information about a user . 
     435      
     436     @param    n         <b>string</b>       Information name 
     437     @return   <b>string</b> Information value 
    456438     */ 
    457439     public function getInfo($n) 
     
    465447      
    466448     /** 
    467      * Returns a specific user option 
    468      *  
    469      * @param string     $n             Option name 
    470      * @return string 
     449     Returns a specific user option 
     450      
     451     @param    n         <b>string</b>       Option name 
     452     @return   <b>string</b> Option value 
    471453     */ 
    472454     public function getOption($n) 
     
    479461      
    480462     /** 
    481      * Returns all user options in an associative array. 
    482      *  
    483      * @return array 
     463     Returns all user options in an associative array. 
     464      
     465     @return   <b>array</b> 
    484466     */ 
    485467     public function getOptions() 
     
    492474     //@{ 
    493475     /** 
    494      * Returns an array with permissions parsed from the string <var>$level</var> 
    495      *  
    496      * @param string     $level         Permissions string 
    497      * @return array 
     476     Returns an array with permissions parsed from the string <var>$level</var> 
     477      
     478     @param    level     <b>string</b>       Permissions string 
     479     @return   <b>array</b> 
    498480     */ 
    499481     public function parsePermissions($level) 
     
    510492      
    511493     /** 
    512      * Returns <var>perm_types</var> property content. 
    513      *  
    514      * @return array 
     494     Returns <var>perm_types</var> property content. 
     495      
     496     @return   <b>array</b> 
    515497     */ 
    516498     public function getPermissionsTypes() 
     
    520502      
    521503     /** 
    522      * Adds a new permission type. 
    523      *  
    524      * @param string     $name          Permission name 
    525      * @param string     $title         Permission title 
     504     Adds a new permission type. 
     505      
     506     @param    name      <b>string</b>       Permission name 
     507     @param    title     <b>string</b>       Permission title 
    526508     */ 
    527509     public function setPermissionType($name,$title) 
     
    534516     //@{ 
    535517     /** 
    536      * Add a recover key to a specific user identified by its email and 
    537      * password. 
    538      *  
    539      * @param string     $user_id       User ID 
    540      * @param string     $user_email    User Email 
    541      * @return string 
     518     Add a recover key to a specific user identified by its email and 
     519     password. 
     520      
     521     @param    user_id        <b>string</b>       User ID 
     522     @param    user_email     <b>string</b>       User Email 
     523     @return   <b>string</b> Recover key 
    542524     */ 
    543525     public function setRecoverKey($user_id,$user_email) 
     
    565547      
    566548     /** 
    567      * Creates a new user password using recovery key. Returns an array: 
    568      *  
    569      * - user_email 
    570      * - user_id 
    571      * - new_pass 
    572      *  
    573      * @param string     $recover_key   Recovery key 
    574      * @return array 
     549     Creates a new user password using recovery key. Returns an array: 
     550      
     551     - user_email 
     552     - user_id 
     553     - new_pass 
     554      
     555     @param    recover_key    <b>string</b>       Recovery key 
     556     @return   <b>array</b> 
    575557     */ 
    576558     public function recoverUserPassword($recover_key) 
     
    608590      
    609591     /** 
    610      * Called after core->addUser 
    611      * @see dcCore::addUser 
    612      * @param cursor     $cur           User cursor 
     592     Called after core->addUser 
     593     @see      dcCore::addUser 
     594     @param    cur       <b>cursor</b>       User cursor 
    613595     */ 
    614596     public function afterAddUser($cur) {} 
    615597      
    616598     /** 
    617      * Called after core->updUser 
    618      * @see dcCore::updUser 
    619      * @param string     $id            User ID 
    620      * @param cursor     $cur           User cursor 
     599     Called after core->updUser 
     600     @see      dcCore::updUser 
     601     @param    id        <b>string</b>       User ID 
     602     @param    cur       <b>cursor</b>       User cursor 
    621603     */ 
    622604     public function afterUpdUser($id,$cur) {} 
    623605      
    624606     /** 
    625      * Called after core->delUser 
    626      * @see dcCore::delUser 
    627      * @param string     $id            User ID 
     607     Called after core->delUser 
     608     @see      dcCore::delUser 
     609     @param    id        <b>string</b>       User ID 
    628610     */ 
    629611     public function afterDelUser($id) {} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map