Пример #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new People();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['People'])) {
         $model->attributes = $_POST['People'];
         if ($model->save()) {
             $model->mid = $model->get_mid();
             $model->save();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $ac = People::getAutoCompleteFields();
     $this->render('create', array('model' => $model, 'ac' => $ac));
 }
Пример #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $name = $request->input("name");
     $age = $request->input("age");
     $people = new People();
     $people->name = $name;
     $people->age = $age;
     $people->save();
     return "name={{$name}}, age={{$age}}";
 }
Пример #3
0
 /**
  * 把一个用户任命为人员页面和处理方法
  * @param integer $uid 用户ID
  */
 public function actionCreate()
 {
     $model = new People();
     $model->categorys = Category::model()->findAll(array('condition' => 'type="teacher"', 'order' => 'weight ASC'));
     if (isset($_POST['People'])) {
         $model->checkUser();
         $model->attributes = $_POST['People'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', '操作成功');
             $this->redirect(array('uploadFace', 'id' => $model->id));
         } else {
             Yii::app()->user->setFlash('error', '操作失败');
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function registerAction()
 {
     echo "RegStart";
     $user = new People();
     //Store and check for errors
     $success = $user->save($this->request->getPost(), array('name', 'email'));
     if ($success) {
         echo "Thanks for registering!";
     } else {
         echo "Sorry, the following problems were generated: ";
         foreach ($user->getMessages() as $message) {
             echo $message->getMessage(), "<br/>";
         }
     }
     $this->view->disable();
 }
Пример #5
0
 /**
  * 设置、取消用户的实验室成员身份
  * @param unknown $id
  */
 public function actionTogglePeople($id)
 {
     $user = $this->loadModel($id);
     $people = $user->people;
     if ($people) {
         if ($people->delete()) {
             Yii::app()->user->setFlash('success', '已将用户移除实验室成员!');
         }
     } else {
         $people = new People();
         $people->name = $user->name;
         $people->userId = $user->id;
         $people->email = $user->email;
         if ($people->save()) {
             Yii::app()->user->setFlash('success', '已将用户设为实验室成员!');
         }
     }
     $this->redirect(array('admin'));
 }
Пример #6
0
 public function actionDependents($id)
 {
     $model = $this->loadModel($id);
     if (isset($_POST['People']['dependent'])) {
         for ($i = 0; $i < 10; ++$i) {
             if (isset($_POST['People']['dependent'][$i])) {
                 if ($pid = $_POST['People']['dependent'][$i]['id']) {
                     $p = People::model()->findByPk($pid);
                 } else {
                     $p = new People();
                 }
                 $p->attributes = $_POST['People']['dependent'][$i];
                 $p->family_id = $model->id;
                 $p->role = 'dependent';
                 $p->save();
             }
         }
     }
     $ppl_ac = People::getAutoCompleteFields();
     $this->render('dependents', array('model' => $model, 'ppl_ac' => $ppl_ac));
 }
Пример #7
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/People.php";
session_start();
if (empty($_SESSION['address_book'])) {
    $_SESSION['address_book'] = array();
}
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('address_book.html.twig', array('people' => People::getAll()));
});
$app->post("/people", function () use($app) {
    $person = new People($_POST['name'], $_POST['phone_number'], $_POST['address']);
    $person->save();
    return $app['twig']->render('add_contact.html.twig', array('newperson' => $person));
});
$app->post("/delete_all", function () use($app) {
    People::deleteAll();
    return $app['twig']->render('delete_all.html.twig');
});
return $app;