function update_profile($profile_id, $data)
{
    $yes_no = array('YES', 'NO');
    $urls = $_SESSION['OCS']['url_service'];
    $profiles = get_profiles();
    $profile = $profiles[$profile_id];
    $updatedProfile = new Profile($profile_id, $data['new_label'] ?: $profile->getLabel());
    foreach ($data['restrictions'] as $key => $val) {
        $updatedProfile->setRestriction($key, $val);
    }
    foreach ($data['config'] as $key => $val) {
        $updatedProfile->setConfig($key, $val);
    }
    foreach ($data['blacklist'] as $key => $val) {
        if ($val == 'YES') {
            $updatedProfile->addToBlacklist($key);
        }
    }
    foreach ($data['pages'] as $key => $val) {
        if ($urls->getUrl($key) and $val == 'on') {
            $updatedProfile->addPage($key);
        }
    }
    $serializer = new XMLProfileSerializer();
    $xml = $serializer->serialize($updatedProfile);
    if (file_put_contents(DOCUMENT_REAL_ROOT . '/config/profiles/' . $profile->getName() . '.xml', $xml)) {
        return $profile->getName();
    } else {
        return false;
    }
}
function get_profile_labels()
{
    $labels = array();
    foreach (get_profiles() as $name => $profile) {
        $labels[$name] = $profile->getLabelTranslated();
    }
    return $labels;
}
//====================================================================================
require_once 'require/function_users.php';
require_once 'require/tables/Table.php';
require_once 'require/tables/Column.php';
require_once 'require/tables/CheckboxColumn.php';
require_once 'require/tables/ActionsColumn.php';
require_once 'require/tables/LinkColumn.php';
require_once MAIN_SECTIONS_DIR . 'ms_users/lib/profile_functions.php';
global $l;
// Remove a profile ?
if ($protectedGet['action'] == 'delete') {
    remove_profile($protectedGet['profile_id']);
}
// SETUP
$form_name = 'ms_profiles';
$profiles = get_profiles();
$detail_url = 'index.php?' . PAG_INDEX . '=' . $pages_refs['ms_profile_details'] . '&profile_id=';
$delete_url = 'index.php?' . PAG_INDEX . '=' . $pages_refs['ms_profiles'] . '&action=delete&profile_id=';
$table = new Table($form_name);
$table->addColumn(new CheckboxColumn('name'));
$table->addColumn(new LinkColumn('name', $l->g(1402), $detail_url, array('required' => true, 'idProperty' => 'name')));
$table->addColumn(new LinkColumn('label_translated', $l->g(1411), $detail_url, array('required' => true, 'idProperty' => 'name')));
$table->addColumn(new ActionsColumn(array($detail_url => 'glyphicon glyphicon-edit', $delete_url => 'glyphicon glyphicon-remove'), 'name'));
if (AJAX) {
    $ajax = true;
    parse_str($protectedPost['ocs']['0'], $params);
    $protectedPost += $params;
    $data = array();
    foreach ($profiles as $profile) {
        $profileData = array();
        foreach ($table->getColumns() as $name => $col) {
function show_profile_edit_form($profile_id)
{
    global $l;
    $yes_no = array('YES' => $l->g(455), 'NO' => $l->g(454));
    $profiles = get_profiles();
    $profile = $profiles[$profile_id];
    echo open_form('edit-profile', '#');
    ?>
	
	<h3><?php 
    echo $l->g(1412);
    ?>
 (<?php 
    echo $profile->getLabelTranslated();
    ?>
)</h3>
	
	<?php 
    show_form_input('name', array('type' => 'hidden', 'value' => $profile->getName()));
    ?>
	<?php 
    show_form_field(array(), array(), 'input', 'new_label', $l->g(1413));
    ?>
	
	<div class="form-frame form-frame-profile">
		<div class="form-column">
			<h4>Restrictions</h4>
			<?php 
    show_restrictions_frame($profile, $yes_no);
    ?>
			
			<br><br><br>
			<h4>Blacklist</h4>
			<?php 
    show_blacklist_frame($profile, $yes_no);
    ?>
		</div>
		
		<div class="form-column">
			<h4>Configuration</h4>
			<?php 
    show_config_frame($profile, $yes_no);
    ?>
		</div>
	</div>
	
	<div class="form-frame form-frame-profile-pages">
		<h4>Pages</h4>
		<?php 
    show_pages_frame($profile, $yes_no);
    ?>
	</div>
	
	<div class="form-buttons">
		<input type="submit" value="<?php 
    echo $l->g(1363);
    ?>
"/>
		<input type="reset" value="<?php 
    echo $l->g(1364);
    ?>
"/>
	</div>
	
	<?php 
    echo close_form();
}
Пример #5
0
        if ($query->is_empty()) {
            $rollback = true;
            return array(SERVER_ERROR, "{\"success\":false}");
        }
        return array(OKAY, json_encode($query->get_row_assoc()));
    });
    http_response_code($code);
    return $json;
}
header('Content-Type: application/json');
if (!abet_is_admin_authenticated()) {
    page_fail(UNAUTHORIZED);
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $obj = new stdClass();
    $obj->courses = get_courses();
    $obj->profiles = get_profiles();
    echo json_encode($obj);
} else {
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        if (!array_key_exists('id', $_POST)) {
            // create new course
            echo create_course(isset($_POST['title']) ? $_POST['title'] : null, isset($_POST['course_number']) ? $_POST['course_number'] : null, isset($_POST['coordinator']) ? $_POST['coordinator'] : null, isset($_POST['instructor']) ? $_POST['instructor'] : null, isset($_POST['description']) ? $_POST['description'] : null, isset($_POST['textbook']) ? $_POST['textbook'] : null, isset($_POST['credit_hours']) ? $_POST['credit_hours'] : null);
        } else {
            // edit existing course
            echo update_course($_POST['id'], isset($_POST['title']) ? $_POST['title'] : null, isset($_POST['course_number']) ? $_POST['course_number'] : null, isset($_POST['coordinator']) ? $_POST['coordinator'] : null, isset($_POST['instructor']) ? $_POST['instructor'] : null, isset($_POST['description']) ? $_POST['description'] : null, isset($_POST['textbook']) ? $_POST['textbook'] : null, isset($_POST['credit_hours']) ? $_POST['credit_hours'] : null);
        }
    } else {
        page_fail(BAD_REQUEST);
    }
}