Пример #1
0
             $temp[$array['name']] = '';
         }
     }
     $params = $temp;
 }
 switch ($case) {
     case 'recruitment':
         if (array_key_exists('deadline', $params)) {
             $deadline = date('Y-m-d', strtotime($params['deadline']));
             $params['deadline'] = $deadline;
         }
         break;
     case 'question':
         if ($params['type'] == 'radio' || $params['type'] == 'checkbox' || $params['type'] == 'dropdown') {
             foreach ($params['existing_choices'] as $choice) {
                 $objDbase->changeField('choice', $choice['id'], array('label' => $choice['label']));
             }
             unset($params['existing_choices']);
             if (!empty($params['new_choices'])) {
                 foreach ($params['new_choices'] as $choice) {
                     $objRecruitment = new Recruitment();
                     $order = $objRecruitment->getChoiceLastPosition($id) + 1;
                     $objDbase->add('choice', array('label' => $choice, 'question_id' => $id, 'order' => $order));
                 }
             }
             unset($params['new_choices']);
         } else {
             if ($params['max'] == 50) {
                 $params['min'] = 10;
             } else {
                 $params['min'] = $params['max'] - 50;
Пример #2
0
require_once '../inc/config.php';
if (isset($_POST['id'], $_POST['object'], $_POST['field'], $_POST['value'])) {
    $id = $_POST['id'];
    $case = $_POST['object'];
    $field = $_POST['field'];
    $value = $_POST['value'];
    if ($value == 0) {
        $new_value = 1;
        if ($case == 'page' && $field == 'default') {
            $objDbase = new dbase();
            $objPage = new Page();
            $page = $objPage->getPages(array('id' => $id))[0];
            $pages = $objPage->getPages(array('default' => 1, 'group_id' => $page['group_id']));
            foreach ($pages as $page) {
                $objDbase->changeField('page', $page['id'], array('default' => 0));
            }
        }
    }
    if ($value == 1) {
        $new_value = 0;
    }
    $objDbase = new dbase();
    $params = array($field => $new_value);
    if ($objDbase->changeField($case, $id, array($field => $new_value))) {
        echo Helper::json(array('success' => true));
    } else {
        echo Helper::json(array('success' => false));
    }
} else {
    echo Helper::json(array('success' => false));
}
Пример #3
0
<?php

require_once '../inc/config.php';
if (isset($_POST['params']) && isset($_POST['object'])) {
    $case = $_POST['object'];
    $errors = array();
    $params = explode('&', $_POST['params']);
    $objDbase = new dbase();
    foreach ($params as $order => $row) {
        $field = str_replace('[]', '', explode('=', $row)[0]);
        $id = explode('=', $row)[1];
        $order++;
        if (!$objDbase->changeField($case, $id, array($field => $order))) {
            $errors[] = $id;
        }
    }
    if (empty($errors)) {
        echo Helper::json(array('error' => false));
    } else {
        throw new Exception(count($errors) . ' records could not be updated');
    }
} else {
    throw new Exception('Missing parameter');
}