Beispiel #1
0
 /**
  * Reset user password and send by email
  */
 public function send_password()
 {
     /**
      * Example 
      */
     BF::load_module('BF_mail');
     BF::load_module("BF_output_template");
     $tpl = new BF_output_template('mail_user_password');
     $user =& $this;
     $tpl->assign('user', $user);
     $tpl->assign('password', $this->reset_password());
     $mail = new BF_mail();
     $mail->From = BF::gu()->_email;
     $mail->FromName = BF::gu()->_username;
     $mail->AddReplyTo($mail->From, $mail->FromName);
     $mail->AddAddress($this->_email);
     $mail->Body = $tpl->disp(false);
     $mail->Subject = $tpl->get_template_vars('subject');
     if ($mail->send()) {
         return true;
     } else {
         throw new exception('Failed sending password mail');
     }
 }
Beispiel #2
0
 /**
  * Logout user
  */
 protected function unregister()
 {
     unset($_SESSION['BF_' . BF::gc('project_id') . '_login_time']);
     unset($_SESSION['BF_' . BF::gc('project_id') . '_logged_id_user']);
     unset($_SESSION['BF_' . BF::gc('project_id') . '_activity_time']);
     // erase the global var pointing to this object
     BF::gu(false);
     // clear all cached data
     $this->_data = array();
 }
Beispiel #3
0
 /**
  * Check if current logged user match a certain access string
  * @param	string	$access_string : Access string. See manual for syntax. Eg. uid:4|-g:groupA&g:groupB
  * @param	user	$user [optional default null] : User to test, null for current user
  * @return bool	true if match, false otherwise
  */
 public static function ga($access_string, $user = null)
 {
     if ($user === null) {
         $user = BF::gu();
     }
     // split with |
     foreach (explode('|', strtolower((string) $access_string)) as $sub_access_string) {
         $sub_match = true;
         // split with &
         foreach (explode('&', $sub_access_string) as $condition) {
             $condition = trim($condition);
             if (!$user && $condition != '-1' && $condition != '' || $user && !$user->ga_condition($condition)) {
                 $sub_match = false;
                 break;
             }
         }
         if ($sub_match) {
             return true;
         }
     }
     return false;
 }