Пример #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Areas();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Areas'])) {
         $model->attributes = $_POST['Areas'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->codarea));
         }
     }
     $this->render('create', array('model' => $model));
 }
Пример #2
0
     //highlight
     $highlight_style = $_POST['highlight']['style'];
     //array
     $highlight_color = array_search(strtoupper($_POST['highlight']['color']), $viewhelper->colorarray);
     $stylebin = '';
     for ($i = 1; $i <= 3; $i++) {
         $stylebin .= empty($highlight_style[$i]) ? '0' : '1';
     }
     $highlight_style = bindec($stylebin);
     if ($highlight_style < 0 || $highlight_style > 7 || $highlight_color < 0 || $highlight_color > 8) {
     } else {
         $highlight_style = $highlight_style . $highlight_color;
         $vals['highlight'] = $highlight_style;
     }
     //end highlight
     $result = $area->save($vals, "update", $id);
 } elseif (!empty($_POST['data']['names'])) {
     $names = explode("\r\n", $_POST['data']['names']);
     $tmp_name = array();
     if (!empty($names)) {
         foreach ($names as $val) {
             $name = $val;
             if (!empty($name)) {
                 $tmp_name[] = "('" . $name . "','" . $_POST['data']['area']['url'] . "','" . $parent_id . "','" . $top_parentid . "','" . $level . "','" . $_POST['data']['area']['display_order'] . "','" . $_POST['data']['area']['areatype_id'] . "')";
             }
         }
         $values = implode(",", $tmp_name);
         $sql = "INSERT INTO {$tb_prefix}areas (name,url,parent_id,top_parentid,level,display_order,areatype_id) VALUES " . $values;
         $result = $pdb->Execute($sql);
     }
 }
Пример #3
0
function admin_research_area()
{
    if (isset($_POST['delete'])) {
        $areas = new Areas();
        if ($a = $areas->find($_POST['delete']['area_id'])) {
            $a->delete();
        }
    }
    if (isset($_POST['edit'])) {
        $areas = new Areas();
        if ($a = $areas->find($_POST['edit']['area_id'])) {
            $a->name = $_POST['edit']['name'];
            $a->description = $_POST['edit']['description'];
            $a->display = $_POST['edit']['display'];
            $a->save();
        }
    }
    if (isset($_POST['new'])) {
        $a = new Areas();
        $a->name = $_POST['new']['name'];
        $a->description = $_POST['new']['description'];
        $a->display = $_POST['new']['display'];
        $a->save();
    }
    global $areas;
    $areas = new Areas();
    $areas = $areas->find();
    render();
}