Exemplo n.º 1
0
 public function Save()
 {
     AssetLoadManager::register('tableList');
     $o_dm = Datamodel::load();
     $t_list = new ca_lists();
     $t_role = $this->getRoleObject();
     $t_role->setMode(ACCESS_WRITE);
     foreach ($t_role->getFormFields() as $vs_f => $va_field_info) {
         $t_role->set($vs_f, $_REQUEST[$vs_f]);
         if ($t_role->numErrors()) {
             $this->request->addActionErrors($t_role->errors(), 'field_' . $vs_f);
         }
     }
     // get vars
     $va_vars = $t_role->get('vars');
     if (!is_array($va_vars)) {
         $va_vars = array();
     }
     // save bundle access settings
     $t_screen = new ca_editor_ui_screens();
     $va_bundle_access_settings = array();
     foreach (ca_users::$s_bundlable_tables as $vs_table) {
         $va_available_bundles = $t_screen->getAvailableBundles($vs_table);
         foreach ($va_available_bundles as $vs_bundle_name => $va_bundle_info) {
             $vs_bundle_name_proc = $vs_table . '_' . str_replace(".", "_", $vs_bundle_name);
             $vn_access = $this->request->getParameter($vs_bundle_name_proc, pInteger);
             $va_bundle_access_settings[$vs_table . '.' . $vs_bundle_name] = $vn_access;
         }
     }
     $va_vars['bundle_access_settings'] = $va_bundle_access_settings;
     if ($t_role->getAppConfig()->get('perform_type_access_checking')) {
         // save type access settings
         $va_type_access_settings = array();
         foreach (ca_users::$s_bundlable_tables as $vs_table) {
             if (!caTableIsActive($vs_table) && $vs_table != 'ca_object_representations') {
                 continue;
             }
             $t_instance = $o_dm->getInstanceByTableName($vs_table, true);
             if (!($vs_list_code = $t_instance->getTypeListCode())) {
                 continue;
             }
             $va_type_ids = $t_list->getItemsForList($vs_list_code, array('idsOnly' => true));
             if (is_array($va_type_ids)) {
                 foreach ($va_type_ids as $vn_i => $vn_item_id) {
                     $vn_access = $this->request->getParameter($vs_table . '_type_' . $vn_item_id, pInteger);
                     $va_type_access_settings[$vs_table . '.' . $vn_item_id] = $vn_access;
                 }
             }
         }
         $va_vars['type_access_settings'] = $va_type_access_settings;
     }
     if ($t_role->getAppConfig()->get('perform_source_access_checking')) {
         // save source access settings
         $va_source_access_settings = array();
         foreach (ca_users::$s_bundlable_tables as $vs_table) {
             if (!caTableIsActive($vs_table) && $vs_table != 'ca_object_representations') {
                 continue;
             }
             $t_instance = $o_dm->getInstanceByTableName($vs_table, true);
             if (!($vs_list_code = $t_instance->getSourceListCode())) {
                 continue;
             }
             $va_source_ids = $t_list->getItemsForList($vs_list_code, array('idsOnly' => true));
             if (is_array($va_source_ids)) {
                 foreach ($va_source_ids as $vn_i => $vn_item_id) {
                     $vn_access = $this->request->getParameter($vs_table . '_source_' . $vn_item_id, pInteger);
                     $va_source_access_settings[$vs_table . '.' . $vn_item_id] = $vn_access;
                 }
             }
             $va_source_access_settings[$vs_table . '_default_id'] = $this->request->getParameter($vs_table . '_default_source', pInteger);
         }
         $va_vars['source_access_settings'] = $va_source_access_settings;
     }
     $va_access_status_settings = array();
     if (is_array($va_access_status_ids = $va_source_ids = $t_list->getItemsForList('access_statuses', array('idsOnly' => true)))) {
         foreach ($va_access_status_ids as $vn_i => $vn_item_id) {
             $vs_access = $this->request->getParameter('access_status_' . $vn_item_id, pString);
             switch ($vs_access) {
                 case 0:
                 case 1:
                     $va_access_status_settings[$vn_item_id] = $vs_access;
                     break;
                 default:
                     $va_access_status_settings[$vn_item_id] = null;
                     break;
             }
         }
     }
     $va_vars['access_status_settings'] = $va_access_status_settings;
     $t_role->set('vars', $va_vars);
     // save actions
     $va_role_action_list = $t_role->getRoleActionList();
     $va_new_role_action_settings = array();
     foreach ($va_role_action_list as $vs_group => $va_group_info) {
         if (caTableIsActive($vs_group) === false && $vs_group != 'ca_object_representations') {
             continue;
         }
         // will return null if group name is not a table name; true if it's an enabled table and false if it's a disabled table
         foreach ($va_group_info['actions'] as $vs_action => $va_action_info) {
             if ($this->request->getParameter($vs_action, pInteger) > 0) {
                 $va_new_role_action_settings[] = $vs_action;
             }
         }
     }
     $t_role->setRoleActions($va_new_role_action_settings);
     AppNavigation::clearMenuBarCache($this->request);
     // clear menu bar cache since role changes may affect content
     if ($this->request->numActionErrors() == 0) {
         if (!$t_role->getPrimaryKey()) {
             $t_role->insert();
             $vs_message = _t("Added role");
         } else {
             $t_role->update();
             $vs_message = _t("Saved changes to role");
         }
         if ($t_role->numErrors()) {
             foreach ($t_role->errors() as $o_e) {
                 $this->request->addActionError($o_e, 'general');
                 $this->notification->addNotification($o_e->getErrorDescription(), __NOTIFICATION_TYPE_ERROR__);
             }
         } else {
             $this->notification->addNotification($vs_message, __NOTIFICATION_TYPE_INFO__);
         }
     } else {
         $this->notification->addNotification(_t("Your entry has errors. See below for details."), __NOTIFICATION_TYPE_ERROR__);
     }
     if ($this->request->numActionErrors()) {
         $this->render('role_edit_html.php');
     } else {
         $this->view->setVar('role_list', $t_role->getRoleList());
         $this->render('role_list_html.php');
     }
 }
/* ----------------------------------------------------------------------
 * app/views/system/preferences_cataloguing_html.php : 
 * ----------------------------------------------------------------------
 * CollectiveAccess
 * Open-source collections management software
 * ----------------------------------------------------------------------
 *
 * Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
 * Copyright 2012 Whirl-i-Gig
 *
 * For more information visit http://www.CollectiveAccess.org
 *
 * This program is free software; you may redistribute it and/or modify it under
 * the terms of the provided license as published by Whirl-i-Gig
 *
 * CollectiveAccess is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 *
 * This source code is free and modifiable under the terms of 
 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
 * the "license.txt" file for details, or visit the CollectiveAccess web site at
 * http://www.CollectiveAccess.org
 *
 * ----------------------------------------------------------------------
 */
$t_user = $this->getVar('t_user');
$vs_group = $this->getVar('group');
?>
<div class="sectionBox">
Exemplo n.º 3
0
/**
 *
 */
function caFilterTableList($pa_tables, $pa_options = null)
{
    require_once __CA_MODELS_DIR__ . '/ca_occurrences.php';
    $o_config = Configuration::load();
    $o_dm = Datamodel::load();
    // assume table display names (*not actual database table names*) are keys and table_nums are values
    $va_filtered_tables = array();
    foreach ($pa_tables as $vs_display_name => $vn_table_num) {
        $vs_display_name = mb_strtolower($vs_display_name, 'UTF-8');
        if (!caTableIsActive($vn_table_num)) {
            continue;
        }
        $vs_table_name = $o_dm->getTableName($vn_table_num);
        switch ($vs_table_name) {
            case 'ca_occurrences':
                $t_occ = new ca_occurrences();
                $va_types = $t_occ->getTypeList();
                $va_type_labels = array();
                foreach ($va_types as $vn_item_id => $va_type_info) {
                    $va_type_labels[] = mb_strtolower($va_type_info['name_plural'], 'UTF-8');
                }
                if (sizeof($va_type_labels)) {
                    if (mb_strlen($vs_label = join('/', $va_type_labels)) > 50) {
                        $vs_label = mb_substr($vs_label, 0, 60) . '...';
                    }
                    $va_filtered_tables[$vs_label] = $vn_table_num;
                } else {
                    $va_filtered_tables[$vs_display_name] = $vn_table_num;
                }
                break;
            default:
                $va_filtered_tables[$vs_display_name] = $vn_table_num;
                break;
        }
    }
    if (caGetOption("sort", $pa_options, true)) {
        ksort($va_filtered_tables);
    }
    return $va_filtered_tables;
}
Exemplo n.º 4
0
            print "</tr>\n";
        }
    }
    if ($vn_c > 0) {
        print "</tr>\n";
    }
    $vn_c = 0;
}
?>
			</table>
		</div>
		<div id="role_bundles">
<?php 
$o_dm = Datamodel::load();
foreach ($va_bundle_list as $vs_table => $va_bundles_by_table) {
    if (!caTableIsActive($vs_table) && $vs_table != 'ca_object_representations') {
        continue;
    }
    print "<table width='100%'>\n";
    print "<tr><td colspan='4'><h1>" . $va_table_names[$vs_table] . "</h1></td></tr>\n";
    print "<tr align='center' valign='middle'><th width='180' align='left'>" . _t('Element') . "</th><th width='180'><a href='#' onclick='jQuery(\".{$vs_table}_bundle_access_none\").prop(\"checked\", 1); return false;'>" . _t('No access') . "</a></th><th width='180'><a href='#' onclick='jQuery(\".{$vs_table}_bundle_access_readonly\").prop(\"checked\", 1); return false;'>" . _t('Read-only access') . "</a></th><th><a href='#' onclick='jQuery(\".{$vs_table}_bundle_access_edit\").prop(\"checked\", 1); return false;'>" . _t('Read/edit access') . "</a></th></tr>\n";
    $t_instance = $o_dm->getInstanceByTableName($vs_table, true);
    $vs_pk = $t_instance->primaryKey();
    foreach ($va_bundles_by_table as $vs_bundle_name => $va_info) {
        print "<tr align='center' valign='middle'>";
        print "<td align='left'>" . $va_info['bundle_info']['display'] . "</td>";
        $vs_access = $va_info['access'];
        if (in_array($vs_bundle_name, array('preferred_labels', $vs_pk))) {
            // don't allow preferred labels and other critical UI fields to be set to readonly
            print "<td>-</td>\n";
        } else {