示例#1
0
 function run()
 {
     echo $this->_produce_borrowing_nav();
     parent::run();
 }
示例#2
0
 function show_admin_associate($row, $options)
 {
     if (!$this->_cur_user_has_edit_privs()) {
         echo '<td class="viewerCol_admin">&nbsp;</td>';
         return;
     }
     $e_rel = $this->admin_page->rel_id;
     $e_id = $this->admin_page->id;
     $e = new entity($e_id);
     $user = new entity($this->admin_page->user_id);
     $e_type = $e->get_value('type');
     static $one_to_many = false;
     static $found_connections = false;
     if (!$found_connections) {
         $found_connections = true;
         $q = 'SELECT * FROM allowable_relationship WHERE id = ' . $e_rel . ' AND required = "yes"';
         $r = db_query($q, 'error selecting connections');
         $ar = mysql_fetch_array($r, MYSQL_ASSOC);
         if ($ar and $ar['connections'] == 'one_to_many') {
             $one_to_many = true;
         } else {
             $one_to_many = false;
         }
     }
     $entity_a_or_b = $this->rel_direction == 'b_to_a' ? 'entity_a' : 'entity_b';
     $lock_check_dir = $this->rel_direction == 'b_to_a' ? 'right' : 'left';
     $link = array('rel_id' => $e_rel, $entity_a_or_b => $row->id());
     if ($this->get_relationship_lock_state() || !$row->user_can_edit_relationship($this->admin_page->rel_id, $user, $lock_check_dir)) {
         $link = '';
         $name = 'Locked';
     } elseif (!$this->select) {
         // B TO A BEHAVIOR
         // if the associated item is borrowed, and that relationship is not in the scope of the current site,
         // we do not provide the DoDisassociate link.
         if ($this->rel_direction == 'b_to_a') {
             if ($row->get_value('sharing') == 'owns' || $this->site_id == $row->get_value('rel_site_id')) {
                 $link = array_merge($link, array('cur_module' => 'DoDisassociate'));
             } else {
                 $link = '';
             }
             $name = 'Deselect';
         } else {
             $link = array_merge($link, array('cur_module' => 'DoDisassociate'));
             $name = 'Deselect';
         }
     } else {
         $link = array_merge($link, array('cur_module' => 'DoAssociate'));
         $name = 'Select';
     }
     //echo '<td class="'.$options[ 'class' ].'"><strong>';
     echo '<td class="viewerCol_admin"><strong>';
     if (!$this->select and $one_to_many) {
         echo 'Selected';
     } else {
         if (!empty($link)) {
             // lets add a CSRF token for the GET request - we should make all these requests go via POST but
             // this is better than nothing to prevent CSRF attacks.
             $link = array_merge($link, array('admin_token' => $this->admin_page->get_admin_token()));
             echo '<a href="' . $this->admin_page->make_link($link) . '">' . $name . '</a>';
         } else {
             echo $name;
         }
     }
     if (reason_user_has_privs($this->admin_page->user_id, 'manage_locks') && $row->relationship_has_lock($this->admin_page->rel_id, $lock_check_dir)) {
         echo ' <img class="lockIndicator" src="' . REASON_HTTP_BASE_PATH . 'ui_images/lock_12px_grey_trans.png" alt="Locked for some users" title="Locked for some users" width="12" height="12" />';
     }
     if (empty($this->admin_page->request[CM_VAR_PREFIX . 'type_id'])) {
         $this->rel_type =& $this->admin_page->module->rel_type;
         // THIS IS HOW THE B TO A WAS CODED - REVIEW AND DELETE THIS CONDITION IF POSSIBLE
         if ($this->rel_direction == 'b_to_a') {
             $ass_mod = new AssociatorModule($this->admin_page);
             $ass_mod->rel_type =& $this->admin_page->module->rel_type;
             $edit_link = $ass_mod->get_second_level_vars();
             $edit_link['new_entity'] = '';
         } else {
             $edit_link = $this->admin_page->module->get_second_level_vars();
             $edit_link['new_entity'] = '';
         }
         $preview_link = $edit_link;
         $preview_link['id'] = $row->id();
         $preview_link['cur_module'] = 'Preview';
         $edit_link['id'] = $row->id();
         $edit_link['cur_module'] = 'Edit';
         $sharing = $row->get_value('sharing');
         $owned = is_array($sharing) ? in_array('owns', $sharing) : $row->get_value('sharing') == 'owns';
         $borrowed = is_array($sharing) ? in_array('borrows', $sharing) : $row->get_value('sharing') == 'borrows';
         echo ' | <a href="' . $this->admin_page->make_link($preview_link) . '">Preview</a>';
         if ($owned && reason_site_can_edit_type($this->site_id, $this->rel_type)) {
             echo ' | <a href="' . $this->admin_page->make_link($edit_link) . '">Edit</a>';
         }
         if ($borrowed) {
             echo ' | Borrowed';
         }
         if ($owned && $borrowed) {
             echo '<p><strong>Note: </strong><em>Item is owned AND borrowed by the site.</em></p>';
         }
         if (!$owned && !$borrowed) {
             echo '<p><strong>Note: </strong><em>Item is not currently owned or borrowed by the site.</em></p>';
         }
     }
     echo '</strong></td>';
 }