/**
  * send a content to a destination.
  *
  * @param integer id of user.
  * @param array content details.
  * @param integer names of destinations.
  */
 public function send($user_id, $blog_post, $destination_names)
 {
     Logger::log("Enter: function ContentRouting::send()");
     global $path_prefix;
     if ($destination_names[0]) {
         foreach ($destination_names[0] as $destination) {
             $sql = "SELECT * FROM {content_routing_destinations}, {routing_destination_types} WHERE user_id = ? AND blog_name = ? AND blog_type = destination_id";
             $res = Dal::query($sql, array($user_id, addslashes($destination)));
             if ($res->numRows() > 0) {
                 $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
                 $blogurl = $row->blog_url;
                 $username = $row->user_name;
                 $password = $row->password;
                 $type = $row->destination_name;
                 require_once "{$path_prefix}/destination/{$type}/{$type}.php";
                 $dest = new $type();
                 $dest->send($blog_post, $blogurl, $username, $password);
             }
         }
     }
     if ($destination_names[1]) {
         $sql = "SELECT * FROM {content_routing_destinations} WHERE blog_type = ?";
         $res = Dal::query($sql, array(4));
         if ($res->numRows() > 0) {
             $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
             $username = $row->user_name;
             $password = $row->password;
             $blogurl = $row->blog_url;
             require_once "{$path_prefix}/destination/OutputThis/OutputThis.php";
             $dest = new OutputThis();
             $dest->send($blog_post, $destination_names[1], $username, $password);
         }
     }
     Logger::log("Exit: function ContentRouting::send()");
     return;
 }
function route_to_outputthis($title, $body)
{
    global $outputthis_username, $outputthis_password, $error_message;
    $external_targets = isset($_POST) && isset($_POST['route_targets_external']) ? $_POST['route_targets_external'] : array();
    /* Selected external targets array */
    //p($external_targets);
    if (count($external_targets)) {
        /* User has selected something from external targets */
        if (in_array(ROUTE_TO_NONE, $external_targets)) {
            $error_message[] = 'Content has not been routed to any of your external blog';
        } else {
            if (in_array(ROUTE_TO_ALL, $external_targets)) {
                $external_targets = $_POST['Allexternal_blog'];
                /* All external targets array */
            }
        }
        for ($i = 0; $i < count($external_targets); $i++) {
            $blog_post = array('title' => $title, 'body' => $body);
            if (!empty($outputthis_username) && !empty($outputthis_password)) {
                $return = OutputThis::send($blog_post, array($external_targets[$i]), $outputthis_username, $outputthis_password);
                if ($return == 1) {
                    /* routing successfull to external blog */
                    $error_message[] = 'Post routed successfully to ' . get_target_name($external_targets[$i]);
                } else {
                    $error_message[] = 'Post routed failed for ' . get_target_name($external_targets[$i]) . '. ' . $return[1];
                }
            }
        }
    }
}
示例#3
0
include_once "{$path_prefix}/api/Theme/Template.php";
if (!$_GET['uid']) {
    $uid = $_SESSION['user']['id'];
} else {
    $uid = $_GET['uid'];
}
$user_destinations = ContentRouting::get_user_destinations((int) $_SESSION['user']['id']);
$dest_output_this = array();
$dest_other = array();
//print_r($user_destinations);exit;
$k = 0;
foreach ($user_destinations as $destination) {
    if ($destination['blog_type'] == 4) {
        $dest_output_this['id'] = $destination['id'];
        $dest_output_this['blog_name'] = $destination['blog_name'];
        $dest_output_this['blog_url'] = $destination['blog_url'];
        $dest_output_this['blog_type'] = $destination['blog_type'];
    } else {
        $dest_other[$k]['id'] = $destination['id'];
        $dest_other[$k]['blog_name'] = $destination['blog_name'];
        $dest_other[$k]['blog_url'] = $destination['blog_url'];
        $dest_other[$k]['blog_type'] = $destination['blog_type'];
        $k++;
    }
}
if ($dest_output_this) {
    $targets = OutputThis::get_targets((int) $dest_output_this['id']);
}
$center_content =& new Template(CURRENT_THEME_FSPATH . "/output_dest.tpl");
$center_content->set('targets', $targets);
print $center_content->fetch();