Exemplo n.º 1
0
    }
    BF::load_module("BF_output_template");
    $tpl = new BF_output_template("view_car");
    $tpl->assign('car', $car);
    $tpl->disp();
} elseif ($action == "save") {
    BF::load_module("BF_form");
    $form = new BF_form('edit_car');
    $car = new car($id);
    if (!$car->exists()) {
        throw new BF_not_found();
    }
    // check
    if (!$form->check()) {
        $form->show_error();
    }
    // process
    $car->name = $form->gval("name");
    $car->price = $form->gval("price");
    $car->save();
    // redirect
    BF::gr("example")->redirect();
} else {
    // list all cars from db
    $list = BF::glist('car');
    // display
    BF::load_module("BF_output_template");
    $tpl = new BF_output_template("list_cars");
    $tpl->assign('list', $list);
    $tpl->disp();
}
Exemplo n.º 2
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');
     }
 }