Exemple #1
0
 /**
  * Check for hijacked URL space
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  * @return boolean Indicating success.
  */
 public function _can_handle_redirect($handler_id, array $args, array &$data)
 {
     // Process the request immediately
     if (isset($args[0])) {
         $mc = net_nemein_redirector_tinyurl_dba::new_collector('node', $this->_topic->guid);
         $mc->add_constraint('name', '=', $args[0]);
         $mc->add_value_property('code');
         $mc->add_value_property('url');
         $mc->execute();
         $results = $mc->list_keys();
         // No results found
         if (count($results) === 0) {
             return false;
         }
         // Catch first the configuration option for showing editing interface instead
         // of redirecting administrators
         if ($this->_topic->can_do('net.nemein.redirector:noredirect') && !$this->_config->get('admin_redirection')) {
             midcom::get()->relocate("{$this->_topic->name}/edit/{$args[0]}/");
         }
         foreach ($results as $guid => $array) {
             $url = $mc->get_subkey($guid, 'url');
             $code = $mc->get_subkey($guid, 'code');
             break;
         }
         // Redirection HTTP code
         if (!$code) {
             $code = $this->_config->get('redirection_code');
         }
         midcom::get()->relocate($url, $code);
         // This will exit
     }
     return true;
 }
Exemple #2
0
 function get_leaves()
 {
     $leaves = array();
     $qb = net_nemein_redirector_tinyurl_dba::new_query_builder();
     $qb->add_constraint('node', '=', $this->_topic->guid);
     $qb->add_order('metadata.score', 'DESC');
     $qb->add_order('title');
     // Get the results
     $results = $qb->execute();
     foreach ($results as $tinyurl) {
         $leaves[$tinyurl->id] = array(MIDCOM_NAV_URL => "{$tinyurl->name}/", MIDCOM_NAV_NAME => $tinyurl->title, MIDCOM_NAV_GUID => $tinyurl->guid, MIDCOM_NAV_OBJECT => $tinyurl);
     }
     return $leaves;
 }
Exemple #3
0
 /**
  * Check for duplicate names
  */
 private function duplicate_names()
 {
     $mc = net_nemein_redirector_tinyurl_dba::new_collector('name', $this->name);
     $mc->add_constraint('node', '=', $this->node);
     // This item already exists, exclude itself from duplicate name check
     if ($this->guid) {
         $mc->add_constraint('guid', '<>', $this->guid);
     }
     $mc->execute();
     if (count($mc->list_keys()) > 0) {
         return true;
     } else {
         return false;
     }
 }
Exemple #4
0
 /**
  * List TinyURLs
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_list($handler_id, array $args, array &$data)
 {
     // Get the topic link and relocate accordingly
     $data['url'] = net_nemein_redirector_viewer::topic_links_to($data);
     $qb = net_nemein_redirector_tinyurl_dba::new_query_builder();
     $qb->add_constraint('node', '=', $this->_topic->guid);
     $this->_tinyurls = $qb->execute();
     // Initialize the datamanager instance
     $this->_datamanager = new midcom_helper_datamanager2_datamanager($this->load_schemadb());
     // Set the request data
     $this->_populate_request_data($handler_id);
 }