Beispiel #1
0
 public function actionAdmin()
 {
     $model = new AdminForm();
     $frequency = KeyValue::model()->findByPk('newsletter_frequency');
     $model->frequency = abs($frequency->value);
     if (isset($_POST['AdminForm'])) {
         $model->attributes = $_POST['AdminForm'];
         if ($model->validate()) {
             if (isset($_POST['yt1']) || $frequency->value < 0) {
                 $frequency->value = -$model->frequency;
             } else {
                 $frequency->value = $model->frequency;
             }
             $frequency->save();
             $this->redirect('admin');
         }
     }
     $newsletter = new Newsletter();
     $this->render('admin', array('newsletter' => $newsletter->make(), 'model' => $model));
 }
Beispiel #2
0
<?php

session_start();
if (isset($_SESSION['type'])) {
    if ($_SESSION['type'] != "Administrator") {
        header('Location: index.php');
    }
} else {
    header('Location: index.php');
}
include "models/admin_model.php";
$admins = new AdminForm();
$to_edit = new AdminForm();
if (isset($_POST['add_admin'])) {
    $to_edit->load_from_post();
    $valid = $to_edit->validate();
    if ($_POST['password2'] != $to_edit->fields['password']->value) {
        $valid = false;
    } else {
        $to_edit->fields['password']->hash_pass();
    }
    if ($valid) {
        $to_edit->save();
    }
} elseif (isset($_POST['admin_id'])) {
    $to_edit->load_by_pk($_POST['admin_id']);
    $to_edit->load_from_post();
    $valid = $to_edit->validate();
    if ($valid) {
        $to_edit->save();
        $to_edit = new AdminForm();