本文整理汇总了PHP中ca_sets::haveAccessToSet方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_sets::haveAccessToSet方法的具体用法?PHP ca_sets::haveAccessToSet怎么用?PHP ca_sets::haveAccessToSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_sets
的用法示例。
在下文中一共展示了ca_sets::haveAccessToSet方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(&$po_request, &$po_response, $pa_view_paths = null)
{
parent::__construct($po_request, $po_response, $pa_view_paths);
// check access to set - if user doesn't have edit access we bail
$t_item = new ca_set_items($po_request->getParameter('item_id', pInteger));
$t_set = new ca_sets($t_item->get('set_id'));
if (!$t_set->haveAccessToSet($po_request->getUserID(), __CA_SET_EDIT_ACCESS__, $t_item->get('set_id'))) {
$this->postError(2320, _t("Access denied"), "SetItemEditorController->__construct()");
}
}
示例2: GetItemInfo
public function GetItemInfo()
{
if ($pn_set_id = $this->request->getParameter('set_id', pInteger)) {
$t_set = new ca_sets($pn_set_id);
if (!$t_set->getPrimaryKey()) {
$this->notification->addNotification(_t("The set does not exist"), __NOTIFICATION_TYPE_ERROR__);
return;
}
// does user have edit access to set?
if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__, null, array('request' => $this->request))) {
$this->notification->addNotification(_t("You cannot edit this set"), __NOTIFICATION_TYPE_ERROR__);
$this->Edit();
return;
}
$pn_table_num = $t_set->get('table_num');
$vn_set_item_count = $t_set->getItemCount(array('user_id' => $this->request->getUserID()));
} else {
$pn_table_num = $this->request->getParameter('table_num', pInteger);
$vn_set_item_count = 0;
}
$pn_row_id = $this->request->getParameter('row_id', pInteger);
$t_row = $this->opo_datamodel->getInstanceByTableNum($pn_table_num, true);
if (!$t_row->load($pn_row_id)) {
$va_errors[] = _t("Row_id is invalid");
}
$this->view->setVar('errors', $va_errors);
$this->view->setVar('set_id', $pn_set_id);
$this->view->setVar('row_id', $pn_row_id);
$this->view->setVar('idno', $t_row->get($t_row->getProperty('ID_NUMBERING_ID_FIELD')));
$this->view->setVar('idno_sort', $t_row->get($t_row->getProperty('ID_NUMBERING_SORT_FIELD')));
$this->view->setVar('set_item_label', $t_row->getLabelForDisplay(false));
if ($vs_template = $this->getRequest()->getParameter('displayTemplate', pString)) {
$this->view->setVar('displayTemplate', $t_row->getWithTemplate($vs_template));
}
$this->view->setVar('representation_tag', '');
if (method_exists($t_row, 'getRepresentations')) {
if ($vn_set_item_count > 50) {
$vs_thumbnail_version = 'tiny';
} else {
$vs_thumbnail_version = "thumbnail";
}
if (sizeof($va_reps = $t_row->getRepresentations(array($vs_thumbnail_version)))) {
$va_rep = array_shift($va_reps);
$this->view->setVar('representation_tag', $va_rep['tags'][$vs_thumbnail_version]);
$this->view->setVar('representation_url', $va_rep['urls'][$vs_thumbnail_version]);
$this->view->setVar('representation_width', $va_rep['info'][$vs_thumbnail_version]['WIDTH']);
$this->view->setVar('representation_height', $va_rep['info'][$vs_thumbnail_version]['HEIGHT']);
}
}
$this->render('ajax_set_item_info_json.php');
}
示例3: getSetXML
public function getSetXML()
{
$pn_set_id = $this->request->getParameter('set_id', pInteger);
$t_set = new ca_sets($pn_set_id);
if (!$t_set->getPrimaryKey()) {
$this->notification->addNotification(_t("The collection does not exist"), __NOTIFICATION_TYPE_ERROR__);
$this->Edit();
return;
}
if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_READ_ACCESS__)) {
$this->notification->addNotification(_t("You cannot view this collection"), __NOTIFICATION_TYPE_INFO__);
$this->response->setRedirect(caNavUrl($this->request, '', 'LoginReg', 'form'));
return;
}
if ($this->request->config->get("dont_enforce_access_settings")) {
$va_access_values = array();
} else {
$va_access_values = caGetUserAccessValues($this->request);
}
$this->view->setVar('set_id', $pn_set_id);
$this->view->setVar('t_set', $t_set);
$this->view->setVar('items', caExtractValuesByUserLocale($t_set->getItems(array('thumbnailVersion' => 'large', 'checkAccess' => $va_access_values, 'user_id' => $this->request->getUserID()))));
$this->render('Sets/xml_set_items.php');
}
示例4: _getSet
/**
* Uses _getSetID() to figure out the ID of the current set, then returns a ca_sets object for it
* and also sets the 'current_set_id' user variable
*/
private function _getSet($vs_access_level = __CA_SET_EDIT_ACCESS__)
{
$t_set = new ca_sets();
$vn_set_id = $this->_getSetID();
if ($vn_set_id) {
$t_set->load($vn_set_id);
if ($t_set->getPrimaryKey() && $t_set->haveAccessToSet($this->request->getUserID(), $vs_access_level)) {
$this->request->user->setVar('current_set_id', $vn_set_id);
# --- pass the access level the user has to the set - needed to display the proper controls in views
$vb_write_access = false;
if ($t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) {
$vb_write_access = true;
}
$this->view->setVar("write_access", $vb_write_access);
return $t_set;
}
}
return null;
}
示例5: info
/**
* Sets up view variables for upper-left-hand info panel (aka. "inspector"). Actual rendering is performed by calling sub-class.
*
* @param array $pa_parameters Array of parameters as specified in navigation.conf, including primary key value and type_id
*/
public function info($pa_parameters)
{
$vn_set_id = $this->request->getParameter('set_id', pInteger);
$o_dm = Datamodel::load();
$t_set = new ca_sets($vn_set_id);
if (!$t_set->getPrimaryKey()) {
die("Invalid set");
}
// Does user have access to set?
if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_READ_ACCESS__)) {
die("You don't have access to the set");
}
$t_item = $o_dm->getInstanceByTableNum($t_set->get('table_num'), true);
$this->view->setVar('t_set', $t_set);
$this->view->setVar('t_item', $t_item);
$this->view->setVar('screen', $this->request->getActionExtra());
// name of screen
$this->view->setVar('result_context', $this->getResultContext());
return $this->render('editor/widget_batch_info_html.php', true);
}
示例6: displaySet
public function displaySet()
{
# --- set info
$t_set = new ca_sets($pn_set_id = $this->request->getParameter('set_id', pInteger));
if (!$t_set->getPrimaryKey()) {
$this->notification->addNotification(_t("This set does not exist"), "message");
$this->response->setRedirect(caNavUrl($this->request, "", "", "", ""));
return;
}
$va_access_values = caGetUserAccessValues($this->request);
# Enforce access control
if (sizeof($va_access_values) && !in_array($t_set->get("access"), $va_access_values)) {
$this->notification->addNotification(_t("This set is not available for view"), "message");
$this->response->setRedirect(caNavUrl($this->request, "", "", "", ""));
return;
}
if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_READ_ACCESS__)) {
$this->notification->addNotification(_t("This set is not available for view"), "message");
$this->response->setRedirect(caNavUrl($this->request, "", "", "", ""));
return;
}
$this->view->setVar('t_set', $t_set);
$va_items = caExtractValuesByUserLocale($t_set->getItems(array('thumbnailVersions' => array('widepreview', 'medium'), 'access' => __CA_SET_READ_ACCESS__, "checkAccess" => $va_access_values, 'user_id' => $this->request->getUserID())));
$this->view->setVar('items', $va_items);
$va_row_ids = array();
foreach ($va_items as $vn_item_id => $va_item_info) {
$va_row_ids[] = $va_item_info['row_id'];
}
# --- all featured sets - for display in right hand column
// get sets for public display
$t_list = new ca_lists();
$vn_public_set_type_id = $t_list->getItemIDFromList('set_types', $t_list->getAppConfig()->get('bristol_set_type'));
$t_set = new ca_sets($pn_set_id);
$va_sets = caExtractValuesByUserLocale($t_set->getSets(array('table' => 'ca_objects', 'access' => __CA_SET_READ_ACCESS__, 'setType' => $vn_public_set_type_id, 'user_id' => $this->request->getUserID())));
$va_set_first_items = array();
$va_set_first_items = $t_set->getFirstItemsFromSets(array_keys($va_sets), array("version" => "icon", "checkAccess" => $va_access_values));
$this->view->setVar('sets', $va_sets);
$this->view->setVar('first_items_from_sets', $va_set_first_items);
$this->view->setVar('set_title', $t_set->getLabelForDisplay());
$this->view->setVar('set_description', $t_set->get($this->opo_plugin_config->get('set_description_element_code'), array('convertLinkBreaks' => true)));
$this->view->setVar('set_creator', $t_set->get('setcreator', array('convertLinkBreaks' => true)));
$this->view->setVar('set_date', $t_set->get('setdate', array('convertLinkBreaks' => true)));
$va_exp_dates = $t_set->getAccessExpirationDates($this->request->getUserID(), __CA_SET_READ_ACCESS__, $pn_set_id);
$this->view->setVar('set_expiration_date', $va_exp_dates[$pn_set_id]);
// Needed to figure out what result context to use on details
$this->opo_result_context->setParameter('set_id', $pn_set_id);
$this->opo_result_context->setResultList($va_row_ids);
$this->opo_result_context->setAsLastFind();
$this->opo_result_context->saveContext();
$this->render($this->ops_theme . '/set_info_html.php');
}
示例7: GetSelectedRepresentationCount
/**
*
*/
public function GetSelectedRepresentationCount()
{
$pn_item_id = $this->request->getParameter('item_id', pInteger);
$t_set_item = new ca_set_items($pn_item_id);
$t_set = new ca_sets($t_set_item->get('set_id'));
if (!$t_set->getPrimaryKey() || !$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) {
// TODO: proper error reporting or redirect?
return;
}
$vn_num_reps_selected = $t_set_item->getSelectedRepresentationCount();
$vn_num_reps = $t_set_item->getRepresentationCount();
$vs_msg = $vn_num_reps == 1 ? _t("%1/%2 page selected", $vn_num_reps_selected, $vn_num_reps) : _t("%1/%2 pages selected", $vn_num_reps_selected, $vn_num_reps);
$this->response->addContent($vs_msg);
}
示例8: importMediaFromDirectory
//.........这里部分代码省略.........
if ($t_set->load($vn_possible_set_id)) {
$vn_set_id = $t_set->getPrimaryKey();
}
} else {
$vs_set_code = mb_substr(preg_replace("![^A-Za-z0-9_\\-]+!", "_", $vs_set_create_name), 0, 100);
if ($t_set->load(array('set_code' => $vs_set_code))) {
$vn_set_id = $t_set->getPrimaryKey();
}
}
if (!$t_set->getPrimaryKey()) {
$t_set->setMode(ACCESS_WRITE);
$t_set->set('user_id', $po_request->getUserID());
$t_set->set('type_id', $po_request->config->get('ca_sets_default_type'));
$t_set->set('table_num', $t_instance->tableNum());
$t_set->set('set_code', $vs_set_code);
$t_set->insert();
if ($t_set->numErrors()) {
$va_notices['create_set'] = array('idno' => '', 'label' => _t('Create set %1', $vs_set_create_name), 'message' => $vs_msg = _t('Failed to create set %1: %2', $vs_set_create_name, join("; ", $t_set->getErrors())), 'status' => 'SET ERROR');
$o_log->logError($vs_msg);
} else {
$t_set->addLabel(array('name' => $vs_set_create_name), $vn_locale_id, null, true);
if ($t_set->numErrors()) {
$va_notices['add_set_label'] = array('idno' => '', 'label' => _t('Add label to set %1', $vs_set_create_name), 'message' => $vs_msg = _t('Failed to add label to set: %1', join("; ", $t_set->getErrors())), 'status' => 'SET ERROR');
$o_log->logError($vs_msg);
}
$vn_set_id = $t_set->getPrimaryKey();
}
}
} else {
$vn_set_id = null;
// no set
}
}
if ($t_set->getPrimaryKey() && !$t_set->haveAccessToSet($po_request->getUserID(), __CA_SET_EDIT_ACCESS__)) {
$va_notices['set_access'] = array('idno' => '', 'label' => _t('You do not have access to set %1', $vs_set_create_name), 'message' => $vs_msg = _t('Cannot add to set %1 because you do not have edit access', $vs_set_create_name), 'status' => 'SET ERROR');
$o_log->logError($vs_msg);
$vn_set_id = null;
$t_set = new ca_sets();
}
$vn_num_items = sizeof($va_files_to_process);
// Get list of regex packages that user can use to extract object idno's from filenames
$va_regex_list = caBatchGetMediaFilenameToIdnoRegexList(array('log' => $o_log));
// Get list of replacements that user can use to transform file names to match object idnos
$va_replacements_list = caBatchGetMediaFilenameReplacementRegexList(array('log' => $o_log));
// Get list of files (or file name patterns) to skip
$va_skip_list = preg_split("![\r\n]+!", $vs_skip_file_list);
foreach ($va_skip_list as $vn_i => $vs_skip) {
if (!strlen($va_skip_list[$vn_i] = trim($vs_skip))) {
unset($va_skip_list[$vn_i]);
}
}
$vn_c = 0;
$vn_start_time = time();
$va_report = array();
foreach ($va_files_to_process as $vs_file) {
$va_tmp = explode("/", $vs_file);
$f = array_pop($va_tmp);
$d = array_pop($va_tmp);
array_push($va_tmp, $d);
$vs_directory = join("/", $va_tmp);
// Skip file names using $vs_skip_file_list
if (BatchProcessor::_skipFile($f, $va_skip_list)) {
$o_log->logInfo(_t('Skipped file %1 because it was on the skipped files list', $f));
continue;
}
$vs_relative_directory = preg_replace("!{$vs_batch_media_import_root_directory}[/]*!", "", $vs_directory);
示例9: RecordRepresentationSelection
public function RecordRepresentationSelection()
{
$pn_item_id = $this->request->getParameter('item_id', pInteger);
$pn_representation_id = $this->request->getParameter('representation_id', pInteger);
$pn_selected = $this->request->getParameter('selected', pInteger);
$va_errors = array();
$t_set_item = new ca_set_items($pn_item_id);
$t_set = new ca_sets($t_set_item->get('set_id'));
if (!$t_set->getPrimaryKey() || !$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) {
// TODO: proper error reporting or redirect?
return;
}
if (!$t_set_item->getPrimaryKey()) {
$va_errors[] = _t("Invalid set item");
}
if (!sizeof($va_errors)) {
$t_set = new ca_sets($t_set_item->get('set_id'));
if (!$t_set->getPrimaryKey()) {
$va_errors[] = _t("Invalid set");
}
if (!$t_set->haveAccessToSet($this->request->getUserID(), __CA_SET_EDIT_ACCESS__)) {
$va_errors[] = _t("You do not have access to this set");
}
if (!sizeof($va_errors)) {
if ((bool) $pn_selected) {
$t_set_item->addSelectedRepresentation($pn_representation_id);
} else {
$t_set_item->removeSelectedRepresentation($pn_representation_id);
}
$t_set_item->update();
$va_errors = $t_set_item->getErrors();
}
}
$this->view->setVar("errors", $va_errors);
$this->view->setVar('representation_id', $pn_representation_id);
$this->view->setVar('item_id', $pn_item_id);
$this->render("ajax_select_representation_json.php");
}
示例10: foreach
<li class="divider"></li>
</ul>
</div><!-- end btn-group -->
</H1>
<div class="row">
<div class="col-sm-10 col-md-9 col-lg-7">
<?php
if (sizeof($va_set_ids)) {
$i = 0;
foreach ($va_set_ids as $vn_set_id) {
if ($i == 0) {
print "<div class='row'>";
}
$i++;
$t_set->load($vn_set_id);
$vb_write_access = $t_set->haveAccessToSet($this->request->getUserID(), 2);
print "<div class='col-xs-6 col-sm-6 col-md-6'>\n";
print caLightboxSetListItem($this->request, $t_set, $va_access_values, array("write_access" => $vb_write_access));
print "\n</div><!-- end col -->\n";
if ($i == 2) {
$i = 0;
print "</div><!-- end row -->";
}
}
if ($i == 1) {
print "</div><!-- end row -->";
}
} else {
print "<div class='row'><div class='col-sm-6 col-md-6'>\n" . caLightboxSetListItemPlaceholder($this->request) . "\n</div><!-- end col --></div><!-- end row -->\n";
}
?>
示例11: importMediaFromDirectory
/**
* @param array $pa_options
* progressCallback =
* reportCallback =
* sendMail =
*/
public static function importMediaFromDirectory($po_request, $pa_options = null)
{
global $g_ui_locale_id;
$t_object = new ca_objects();
$o_eventlog = new Eventlog();
$t_set = new ca_sets();
$va_notices = $va_errors = array();
$vb_we_set_transaction = false;
$o_trans = isset($pa_options['transaction']) && $pa_options['transaction'] ? $pa_options['transaction'] : null;
if (!$o_trans) {
$vb_we_set_transaction = true;
$o_trans = new Transaction();
}
$o_log = new Batchlog(array('user_id' => $po_request->getUserID(), 'batch_type' => 'MI', 'table_num' => (int) $t_object->tableNum(), 'notes' => '', 'transaction' => $o_trans));
if (!is_dir($pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Specified import directory is invalid"));
return null;
}
$vs_batch_media_import_root_directory = $po_request->config->get('batch_media_import_root_directory');
if (!preg_match("!^{$vs_batch_media_import_root_directory}!", $pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Specified import directory is invalid"));
return null;
}
if (preg_match("!/\\.\\.!", $vs_directory) || preg_match("!\\.\\./!", $pa_options['importFromDirectory'])) {
$o_eventlog->log(array("CODE" => 'ERR', "SOURCE" => "mediaImport", "MESSAGE" => "Specified import directory is invalid"));
return null;
}
$vb_include_subdirectories = (bool) $pa_options['includeSubDirectories'];
$vb_delete_media_on_import = (bool) $pa_options['deleteMediaOnImport'];
$vs_import_mode = $pa_options['importMode'];
$vs_match_mode = $pa_options['matchMode'];
$vn_object_type_id = $pa_options['ca_objects_type_id'];
$vn_rep_type_id = $pa_options['ca_object_representations_type_id'];
$vn_object_access = $pa_options['ca_objects_access'];
$vn_object_representation_access = $pa_options['ca_object_representations_access'];
$vn_object_status = $pa_options['ca_objects_status'];
$vn_object_representation_status = $pa_options['ca_object_representations_status'];
$vs_idno_mode = $pa_options['idnoMode'];
$vs_idno = $pa_options['idno'];
$vs_set_mode = $pa_options['setMode'];
$vs_set_create_name = $pa_options['setCreateName'];
$vn_set_id = $pa_options['set_id'];
$vn_locale_id = $pa_options['locale_id'];
$vs_skip_file_list = $pa_options['skipFileList'];
$va_relationship_type_id_for = array();
if (is_array($va_create_relationship_for = $pa_options['create_relationship_for'])) {
foreach ($va_create_relationship_for as $vs_rel_table) {
$va_relationship_type_id_for[$vs_rel_table] = $pa_options['relationship_type_id_for_' . $vs_rel_table];
}
}
if (!$vn_locale_id) {
$vn_locale_id = $g_ui_locale_id;
}
$va_files_to_process = caGetDirectoryContentsAsList($pa_options['importFromDirectory'], $vb_include_subdirectories);
if ($vs_set_mode == 'add') {
$t_set->load($vn_set_id);
} else {
if ($vs_set_mode == 'create' && $vs_set_create_name) {
$va_set_ids = $t_set->getSets(array('user_id' => $po_request->getUserID(), 'table' => 'ca_objects', 'access' => __CA_SET_EDIT_ACCESS__, 'setIDsOnly' => true, 'name' => $vs_set_create_name));
$vn_set_id = null;
if (is_array($va_set_ids) && sizeof($va_set_ids) > 0) {
$vn_possible_set_id = array_shift($va_set_ids);
if ($t_set->load($vn_possible_set_id)) {
$vn_set_id = $t_set->getPrimaryKey();
}
} else {
$vs_set_code = mb_substr(preg_replace("![^A-Za-z0-9_\\-]+!", "_", $vs_set_create_name), 0, 100);
if ($t_set->load(array('set_code' => $vs_set_code))) {
$vn_set_id = $t_set->getPrimaryKey();
}
}
if (!$t_set->getPrimaryKey()) {
$t_set->setMode(ACCESS_WRITE);
$t_set->set('user_id', $po_request->getUserID());
$t_set->set('type_id', $po_request->config->get('ca_sets_default_type'));
$t_set->set('table_num', $t_object->tableNum());
$t_set->set('set_code', $vs_set_code);
$t_set->insert();
if ($t_set->numErrors()) {
$va_notices['create_set'] = array('idno' => '', 'label' => _t('Create set %1', $vs_set_create_name), 'message' => _t('Failed to create set %1: %2', $vs_set_create_name, join("; ", $t_set->getErrors())), 'status' => 'SET ERROR');
} else {
$t_set->addLabel(array('name' => $vs_set_create_name), $vn_locale_id, null, true);
if ($t_set->numErrors()) {
$va_notices['add_set_label'] = array('idno' => '', 'label' => _t('Add label to set %1', $vs_set_create_name), 'message' => _t('Failed to add label to set: %1', join("; ", $t_set->getErrors())), 'status' => 'SET ERROR');
}
$vn_set_id = $t_set->getPrimaryKey();
}
}
} else {
$vn_set_id = null;
// no set
}
}
if ($t_set->getPrimaryKey() && !$t_set->haveAccessToSet($po_request->getUserID(), __CA_SET_EDIT_ACCESS__)) {
//.........这里部分代码省略.........