Example #1
0
 function update()
 {
     // Get all posts with meta_key _coauthor
     $all_posts = get_posts(array('numberposts' => '-1'));
     //echo '<p>returned posts ('.count($all_posts).'):</p>';
     //print_r($posts);
     //echo '<hr />';
     if (is_array($all_posts)) {
         foreach ($all_posts as $single_post) {
             // reset execution time limit
             set_time_limit(60);
             // create new array
             $coauthors = array();
             // get author id -- try to use get_profile
             $coauthors[] = get_profile_by_id('user_login', (int) $single_post->post_author);
             // get coauthors id
             $legacy_coauthors = get_post_meta($single_post->ID, '_coauthor');
             //print_r($legacy_coauthors);
             //echo '<hr />';
             if (is_array($legacy_coauthors)) {
                 //echo '<p>Has Legacy coauthors';
                 foreach ($legacy_coauthors as $legacy_coauthor) {
                     $legacy_coauthor_login = get_profile_by_id('user_login', (int) $legacy_coauthor);
                     if ($legacy_coauthor_login) {
                         $coauthors[] = $legacy_coauthor_login;
                     }
                 }
             } else {
                 //echo '<p>No Legacy coauthors';
             }
             //echo '<p>Post '.$single_post->ID;
             //print_r($coauthors);
             //echo '<hr />';
             $this->add_coauthors($single_post->ID, $coauthors);
         }
     }
 }
Example #2
0
/**
 * Return the guestname for a specific guest
 * @ingroup GUEST_MANAGEMENT
 * @param $guestid [in] Guest name
 * @return guest name in full
 */
function get_guestname($guestid)
{
    global $conn;
    if (!$conn) {
        $conn = connect_Hotel_db(HOST, USER, PASS, DB, PORT);
    }
    if (!$conn) {
        return "";
    }
    if (!$guestid) {
        return "";
    }
    $nm = "";
    if (is_ebridgeCustomer()) {
        include_once dirname(__FILE__) . "/OTA/advancedFeatures/adv_functions.php";
        $profile = array();
        get_profile_by_id($guestid, $profile);
        $nm = get_salutation_bySalutationID($profile['salutation']) . " " . $profile['firstname'];
        if (!empty($profile['middlename'])) {
            $nm .= " " . $profile['middlename'];
        }
        $nm .= " " . $profile['lastname'];
    } else {
        //check on wether search is being done on idno/ppno/guestid/guestname
        $sql = "select firstname, middlename, lastname from guests where guestid=" . strip_specials($guestid);
        //	print $sql."<br/>\n";
        $stmt1 = $conn->prepare($sql);
        $results = $stmt1->execute();
        if ($results) {
            $row = $stmt1->fetch();
            $nm = trim(trim($row['firstname']) . " " . trim($row['middlename']) . " " . trim($row['lastname']));
            //		print "name ".trim(trim($row['firstname'])." ".trim($row['middlename'])." ".trim($row['lastname']))."<br/>";
        }
    }
    return $nm;
}