name.$checkPid.$checkPerm); if (($output = cache_get($cache_key))===0) { $roles = $user->roles; if (in_array('administrator',$roles)) { $ret = true; } else { module_load_include('inc', 'fedora_repository', 'api/fedora_item'); $found = array(); foreach ($roles as $role) { if (preg_match('/^(([A-Za-z0-9]|-|\.)+:(([A-Za-z0-9])|-|\.|~|_|(%[0-9A-F]{2}))+)\s+(write|read)/',$role,$matches)) { $pid = $matches[1]; $perm = $matches[6]; if ($perm == $checkPerm) { $found[]=$pid; } } } if (count($found) > 0) { if (in_array($checkPid,$found)) { $ret = TRUE; } $item=new Fedora_Item($checkPid); $rels=$item->get_relationships(); if (count($rels) > 0) { foreach ($rels as $rel) { $ret = $ret || fedora_fesl_check_roles($rel['object'],$checkPerm); } } } } cache_set($cache_key,$ret,'cache',time()+variable_get('fedora_image_blocks_cache_time',3600)); } else { if (is_object($output)) { $ret=$output->data; } } } return $ret; } function fedora_fesl_block($op = 'list', $delta = 0, $edit = array()) { // The $op parameter determines what piece of information is being requested. switch ($op) { case 'list': // If $op is "list", we just need to return a list of block descriptions. // This is used to provide a list of possible blocks to the administrator, // end users will not see these descriptions. $blocks[0] = array( 'info' => t('FeSL Collections Listing Block'), ); return $blocks; case 'configure': $form = array(); switch ($delta) { case 0: /* $form['fedora_image_rotator_block_numimages'] = array( '#type'=>'textfield', '#title' => t('The number of images to display in the block.'), '#default_value' => variable_get('fedora_image_rotator_block_numimages',1));*/ break; } return $form; case 'save': // If $op is "save", we need to save settings from the configuration form. // Since the first block is the only one that allows configuration, we // need to check $delta to make sure we only save it. switch ($delta) { case 0: // variable_set('fedora_image_rotator_block_query', $edit['fedora_image_rotator_block_query']); break; } return; case 'view': default: // If $op is "view", then we need to generate the block for display // purposes. The $delta parameter tells us which block is being requested. switch ($delta) { case 0: module_load_include('inc', 'fedora_fesl', 'fesl_block'); $block['subject'] = t('My Collections'); $block['content'] = _fedora_fesl_block_content(); break; } return $block; } }