コード例 #1
0
 function init()
 {
     if (!$this->should_run()) {
         trigger_error('Associator module needs an ID to run; none provided.');
         return;
     }
     reason_include_once('classes/filter.php');
     reason_include_once('content_listers/associate.php');
     include_once CARL_UTIL_INC . 'basic/misc.php';
     $this->head_items->add_javascript(JQUERY_URL, true);
     $this->head_items->add_stylesheet(REASON_ADMIN_CSS_DIRECTORY . 'assoc.css');
     $this->head_items->add_javascript(WEB_JAVASCRIPT_PATH . 'table_update.js');
     $this->head_items->add_javascript(WEB_JAVASCRIPT_PATH . 'associator.js');
     $this->get_associations();
     if (empty($this->associations[$this->admin_page->rel_id])) {
         trigger_error($this->admin_page->rel_id . ' is not a valid relationship type id');
         die;
     }
     $current_assoc = $this->associations[$this->admin_page->rel_id];
     $type = new entity($current_assoc['e_id']);
     // save the type entity in an object scope
     $this->rel_type = carl_clone($type);
     $this->admin_page->title = 'Selecting ' . $type->get_value('name');
     $entity = new entity($this->admin_page->id);
     $user = new entity($this->admin_page->user_id);
     if (!$entity->user_can_edit_relationship($this->admin_page->rel_id, $user, $this->_rel_direction)) {
         $this->_locked = true;
     } elseif ($entity->relationship_has_lock($this->admin_page->rel_id, $this->_rel_direction) && reason_user_has_privs($this->admin_page->user_id, 'manage_locks')) {
         $this->_show_lock_info = true;
     }
     $this->get_views($type->id());
     if (empty($this->views)) {
         //add generic lister if not already present
         $this->views = array();
     } else {
         reset($this->views);
         $c = current($this->views);
         if ($c) {
             $lister = $c->id();
             $this->admin_page->request['lister'] = $lister;
         } else {
             $lister = '';
         }
     }
     $lister = isset($lister) ? $lister : '';
     $this->get_viewer($this->admin_page->site_id, $type->id(), $lister);
     $this->filter = new filter();
     $this->filter->set_page($this->admin_page);
     $this->filter->grab_fields($this->viewer->filters);
 }