예제 #1
0
/**
 * Upgrades orders using the old item structure
 * @return void
 */
function appthemes_upgrade_item_addons()
{
    // Get All Orders
    $posts = new WP_Query(array('post_type' => APPTHEMES_ORDER_PTYPE, 'nopaging' => true));
    foreach ($posts->posts as $order) {
        $connected = new WP_Query(array('connected_type' => APPTHEMES_ORDER_CONNECTION, 'connected_from' => $order->ID));
        // Get all items
        foreach ($connected->posts as $post) {
            $post_id = $post->ID;
            // Get all addons
            $meta = p2p_get_meta($post->p2p_id);
            // Don't upgrade new items
            if (isset($meta['type'])) {
                continue;
            }
            if (isset($meta['addon'])) {
                foreach ($meta['addon'] as $addon) {
                    // Add an item for each addon
                    $p2p_id = p2p_type(APPTHEMES_ORDER_CONNECTION)->connect($order->ID, $post_id);
                    // Add meta data
                    p2p_add_meta($p2p_id, 'type', $addon);
                    p2p_add_meta($p2p_id, 'price', $meta[$addon][0]);
                }
            }
            // Add an item for the regular item
            $p2p_id = p2p_type(APPTHEMES_ORDER_CONNECTION)->connect($order->ID, $post_id);
            p2p_add_meta($p2p_id, 'type', 'regular');
            // value of VA_ITEM_REGULAR, since upgrade is only Vantage-applicable
            p2p_add_meta($p2p_id, 'price', $meta['price'][0]);
            // Delete the old item
            p2p_delete_connection($post->p2p_id);
        }
    }
}
function p2pdc_duplicate_connections($new_post_id, $old_post_object)
{
    // get all connection types for post type
    $relationships = p2pdc_list_relationships(get_post_type($old_post_object));
    foreach ($relationships as $relationship) {
        if ($relationship->post_type == 'user') {
            $users = get_users(array('connected_type' => $relationship->name, 'connected_items' => $old_post_object));
            foreach ($users as $user) {
                $connection_meta = array();
                foreach ($relationship->fields as $field) {
                    $connection_meta[$field] = p2p_get_meta($user->p2p_id, $field, true);
                }
                if ($relationship->direction == 'to') {
                    p2p_type($relationship->name)->connect($new_post_id, $user->ID, $connection_meta);
                } else {
                    p2p_type($relationship->name)->connect($user->ID, $new_post_id, $connection_meta);
                }
            }
        } else {
            $connected = new WP_Query(array('connected_type' => $relationship->name, 'connected_items' => $old_post_object, 'nopaging' => true));
            foreach ($connected->posts as $post) {
                $connection_meta = array();
                foreach ($relationship->fields as $field) {
                    $connection_meta[$field] = p2p_get_meta($post->p2p_id, $field, true);
                }
                if ($relationship->direction == 'to') {
                    p2p_type($relationship->name)->connect($new_post_id, $post->ID, $connection_meta);
                } else {
                    p2p_type($relationship->name)->connect($post->ID, $new_post_id, $connection_meta);
                }
            }
        }
    }
}
예제 #3
0
 public static function retrieve($order_id)
 {
     $order_data = get_post($order_id);
     if ($order_data->post_type != APPTHEMES_ORDER_PTYPE) {
         return false;
     }
     $order_gateway = get_post_meta($order_id, "gateway", true);
     $order_ip_address = get_post_meta($order_id, "ip_address", true);
     $order_currency = get_post_meta($order_id, "currency", true);
     $connected = new WP_Query(array('connected_type' => APPTHEMES_ORDER_CONNECTION, 'connected_from' => $order_id, 'post_status' => '-1'));
     $items = array();
     foreach ($connected->posts as $post) {
         $meta = p2p_get_meta($post->p2p_id);
         $item = array('post' => $post, 'price' => $meta['price'][0], 'addons' => array());
         if (isset($meta['addon'])) {
             foreach ($meta['addon'] as $addon) {
                 $item['addons'][] = array("addon_id" => $addon, "price" => $meta[$addon][0]);
             }
         }
         $items[] = $item;
     }
     $return_url = get_permalink($order_data->ID);
     $cancel_url = add_query_arg("cancel", 1, $return_url);
     return new APP_Order($order_data, $order_gateway, $order_ip_address, $order_currency, $items, $return_url, $cancel_url);
 }
예제 #4
0
 /**
  * Retrieves an array of an order's items
  * @param int $order_id The Order ID
  * @return array
  */
 protected static function get_order_items($order_id)
 {
     $items = array();
     foreach (_appthemes_orders_get_connected($order_id)->posts as $post) {
         $meta = p2p_get_meta($post->p2p_id);
         $items[] = array('type' => $meta['type'][0], 'price' => $meta['price'][0], 'post_id' => $post->ID, 'post' => $post, 'unique_id' => $post->p2p_id);
     }
     return $items;
 }
예제 #5
0
 function render($p2p_id, $post_id)
 {
     $args = array('name' => $this->key, 'type' => $this->data['type']);
     if (isset($this->data['values'])) {
         $args['value'] = $this->data['values'];
     }
     $single_value = 'checkbox' != $args['type'];
     $data = array($this->key => p2p_get_meta($p2p_id, $this->key, $single_value));
     $form = new scbForm($data, array('p2p_meta', $p2p_id));
     return $form->input($args);
 }
function sfhiv_group_page_list_group_members()
{
    if (!is_singular('sfhiv_group')) {
        return;
    }
    if (sfhiv_group_has_members()) {
        $users = sfhiv_group_get_members();
        ?>
	<section id="members" class="list">
		<h2 class="list-title">Members</h2>
		<?php 
        $groupings = array();
        foreach ($users as $user) {
            if (p2p_get_meta($user->p2p_id, 'group', true)) {
                $name = p2p_get_meta($user->p2p_id, 'group', true);
                if (!isset($groupings[$name])) {
                    $groupings[$name] = array();
                }
                array_push($groupings[$name], $user);
            } else {
                include locate_template('list-member.php');
            }
        }
        foreach ($groupings as $title => $users) {
            echo '<h3 class="list-title">';
            _e($title, 'sfhiv_theme');
            echo '</h3>';
            foreach ($users as $user) {
                include locate_template('list-member.php');
            }
        }
        ?>
		<br class="clear" />
	</section><!-- #members -->
	<?php 
    }
}
예제 #7
0
 /**
  * Get another post in an ordered connection.
  *
  * @param int The first end of the connection.
  * @param int The second end of the connection.
  * @param int The position relative to the first parameter
  *
  * @return bool|object False on failure, post object on success
  */
 public function get_adjacent($from, $to, $which)
 {
     // The direction needs to be based on the second parameter,
     // so that it's consistent with $this->connect( $from, $to ) etc.
     $directed = $this->find_direction($to);
     if (!$directed) {
         return false;
     }
     $key = $directed->get_orderby_key();
     if (!$key) {
         return false;
     }
     $p2p_id = $directed->get_p2p_id($to, $from);
     if (!$p2p_id) {
         return false;
     }
     $order = (int) p2p_get_meta($p2p_id, $key, true);
     $adjacent = $directed->get_connected($to, array('connected_meta' => array(array('key' => $directed->get_orderby_key(), 'value' => $order + $which))), 'abstract');
     return _p2p_first($adjacent->items);
 }
예제 #8
0
 function __get($key)
 {
     return p2p_get_meta($this->p2p_id, $key, true);
 }
예제 #9
0
 /**
  * Get another post in an ordered connection.
  *
  * @param int The first end of the connection.
  * @param int The second end of the connection.
  * @param int The position relative to the first parameter
  *
  * @return bool|object False on failure, post object on success
  */
 public function get_adjacent($from, $to, $which)
 {
     // The direction needs to be based on the second parameter,
     // so that it's consistent with $this->connect( $from, $to ) etc.
     $r = $this->direction_from_item($to);
     if (!$r) {
         return false;
     }
     list($direction, $to) = $r;
     $directed = $this->set_direction($direction);
     $key = $directed->get_orderby_key();
     if (!$key) {
         return false;
     }
     $p2p_id = $directed->get_p2p_id($to, $from);
     if (!$p2p_id) {
         return false;
     }
     $order = (int) p2p_get_meta($p2p_id, $key, true);
     $adjacent = $directed->get_connected($to, array('connected_meta' => array(array('key' => $key, 'value' => $order + $which))), 'abstract');
     if (empty($adjacent->items)) {
         return false;
     }
     $item = reset($adjacent->items);
     return $item->get_object();
 }
function sfhiv_group_member_get_object($user)
{
    return $member = array("ID" => $user->ID, "display_name" => $user->display_name, "p2p_id" => $user->p2p_id, "first_name" => get_user_meta($user->ID, "first_name", true), "last_name" => get_user_meta($user->ID, "last_name", true), 'hide' => p2p_get_meta($user->p2p_id, 'hide', true), 'title' => p2p_get_meta($user->p2p_id, 'title', true), 'weight' => p2p_get_meta($user->p2p_id, 'weight', true), 'group' => p2p_get_meta($user->p2p_id, 'group', true), 'show_contact_info' => p2p_get_meta($user->p2p_id, 'hide', true));
}
예제 #11
0
function frl_task_candidate_markup(WP_User $candidate, $mode = 1)
{
    $member_url = trailingslashit(site_url('/members/' . $candidate->user_login));
    ?>
<div class="c-img">
	<?php 
    tst_temp_avatar($candidate);
    ?>
</div>
<div class="c-name">
	<a href="<?php 
    echo $member_url;
    ?>
"><?php 
    echo $candidate->first_name . ' ' . $candidate->last_name;
    ?>
</a>
	<div class="user-rating"><?php 
    echo __('Rating', 'tst') . ': <span>' . tst_get_user_rating($candidate->ID) . '</span>';
    ?>
</div>
</div>
<div class="c-actions">
	<?php 
    if (p2p_get_meta($candidate->p2p_id, 'is_approved', true)) {
        ?>

		<span class="candidate-approved">
			<span class="c-status-app btn btn-success btn-xs"><span class="glyphicon glyphicon-ok"></span></span>
		</span>

		<?php 
        if ($mode >= 1 && $mode <= 2) {
            ?>
		 
		<span class="candidate-refuse" data-link-id="<?php 
            echo $candidate->p2p_id;
            ?>
" data-doer-id="<?php 
            echo $candidate->ID;
            ?>
" data-task-id="<?php 
            the_ID();
            ?>
" data-nonce="<?php 
            echo wp_create_nonce($candidate->p2p_id . '-candidate-refuse-' . $candidate->ID);
            ?>
">
			<span class="btn btn-danger btn-xs"><?php 
            _e('Disapprove', 'tst');
            ?>
</span>
		</span>

		<?php 
        }
    } else {
        ?>
	
		<span class="candidate-li">
			<span class="c-status-napp btn btn-success btn-xs"><span class="glyphicon glyphicon-ok"></span></span>
		</span>
	
		<?php 
        if ($mode == 1) {
            ?>

		<span class="candidate-ok" data-link-id="<?php 
            echo $candidate->p2p_id;
            ?>
" data-doer-id="<?php 
            echo $candidate->ID;
            ?>
" data-task-id="<?php 
            the_ID();
            ?>
" data-nonce="<?php 
            echo wp_create_nonce($candidate->p2p_id . '-candidate-ok-' . $candidate->ID);
            ?>
">
			<span class="btn btn-default btn-xs"><?php 
            _e('Approve', 'tst');
            ?>
</span>
		</span>
		<?php 
        }
        ?>

		

	<?php 
    }
    ?>
</div>

<?php 
}
예제 #12
0
function list_related_by_type($post_id, $type, $title = '')
{
    global $post;
    $query_args = array('connected_type' => 'project_post', 'connected_items' => intval($post_id), 'nopaging' => true, 'connected_meta' => array(array('key' => 'type', 'value' => $type)));
    $query = new WP_Query($query_args);
    if ($query->have_posts()) {
        if (empty($title)) {
            $title = __('Related items', 'frl');
        }
        ?>
    
    <h3><?php 
        echo $title;
        ?>
</h3>    
    <ul class='related-items <?php 
        echo esc_attr($type);
        ?>
'>
    
<?php 
        while ($query->have_posts()) {
            $query->the_post();
            ?>
    <li>
        <a href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
        <span class="comment-meta"><?php 
            echo p2p_get_meta($post->p2p_id, 'comment', true);
            ?>
</span>
    </li>
<?php 
        }
        ?>

    </ul>
<?php 
    }
}
예제 #13
0
function tst_is_user_candidate($user_id = false, $task_id = false)
{
    $user_id = $user_id ? $user_id : get_current_user_id();
    if (!$user_id) {
        return false;
    }
    if (!$task_id) {
        global $post;
        $task_id = $post->ID;
    }
    $p2p_id = p2p_type('task-doers')->get_p2p_id($user_id, $task_id);
    if ($p2p_id) {
        // connection exists
        return (int) p2p_get_meta($p2p_id, 'is_approved', true) ? 2 : 1;
    }
    return 0;
}
예제 #14
0
 /**
  * Get another post in an ordered connection.
  *
  * @param int The first end of the connection.
  * @param int The second end of the connection.
  * @param int The position relative to the first parameter
  *
  * @return bool|object False on failure, post object on success
  */
 public function get_adjacent($from, $to, $which)
 {
     $directed = $this->find_direction($to);
     if (!$directed) {
         return false;
     }
     if (!method_exists($directed, 'get_orderby_key')) {
         return false;
     }
     $p2p_id = $directed->get_p2p_id($to, $from);
     if (!$p2p_id) {
         return false;
     }
     $order = (int) p2p_get_meta($p2p_id, $directed->get_orderby_key(), true);
     $adjacent = $directed->get_connected($to, array('connected_meta' => array(array('key' => $directed->get_orderby_key(), 'value' => $order + $which))))->posts;
     if (empty($adjacent)) {
         return false;
     }
     return $adjacent[0];
 }
예제 #15
0
 function get_attached_domains()
 {
     //lazy load the attached domains
     if ($this->_attached_domains === false) {
         //load all connected domains
         $domains = $this->get_domains();
         $this->_attached_domains = array();
         if ($domains) {
             //mark the licensekey as activated
             $this->activated = true;
             //loop thru all domains and if they are attached then increment attached_count
             foreach ($domains as $domain) {
                 $attached = p2p_get_meta($domain->p2p_id, 'attached', true);
                 //ignore localhost domains
                 $domain_object = foolic_domain::get($domain);
                 if ($attached == "1" && $domain_object->localhost === false) {
                     $this->_attached_domains[] = $domain_object;
                 }
             }
         }
     }
     return $this->_attached_domains;
 }
		<?php 
    if (get_the_author_meta('sfhiv_department', $user->ID)) {
        ?>
		<span class="info department"><?php 
        echo get_the_author_meta('sfhiv_department', $user->ID);
        ?>
</span>
		<?php 
    }
    ?>
		<?php 
}
?>
	</section>
	<?php 
if ($show_contact_info || p2p_get_meta($user->p2p_id, 'show_contact_info', true)) {
    ?>
	<section class="contact">
		<?php 
    if (get_the_author_meta('sfhiv_telephone', $user->ID)) {
        ?>
		<span class="info phone"><i></i> <?php 
        echo get_the_author_meta('sfhiv_telephone', $user->ID);
        ?>
</span>
		<?php 
    }
    ?>
		<?php 
    if (get_the_author_meta('email', $user->ID)) {
        ?>
 /**
  * Collect metadata from all boxes.
  */
 static function save_post($post_id, $post)
 {
     if ('revision' == $post->post_type || defined('DOING_AJAX')) {
         return;
     }
     // Custom fields
     if (isset($_POST['p2p_types'])) {
         foreach ($_POST['p2p_types'] as $p2p_type) {
             $ctype = p2p_type($p2p_type);
             if (!$ctype) {
                 continue;
             }
             foreach ($ctype->get_connections($post_id) as $p2p_id => $item_id) {
                 $data = scbForms::get_value(array('p2p_meta', $p2p_id), $_POST, array());
                 foreach (self::$box_args[$p2p_type]->fields as $key => $field_args) {
                     if ('checkbox' == $field_args['type']) {
                         $new_values = scbForms::get_value($key, $data, array());
                         $old_values = p2p_get_meta($p2p_id, $key);
                         foreach (array_diff($new_values, $old_values) as $value) {
                             p2p_add_meta($p2p_id, $key, $value);
                         }
                         foreach (array_diff($old_values, $new_values) as $value) {
                             p2p_delete_meta($p2p_id, $key, $value);
                         }
                     } else {
                         p2p_update_meta($p2p_id, $key, $data[$key]);
                     }
                 }
             }
         }
     }
     // Ordering
     if (isset($_POST['p2p_order'])) {
         foreach ($_POST['p2p_order'] as $key => $list) {
             foreach ($list as $i => $p2p_id) {
                 p2p_update_meta($p2p_id, $key, $i);
             }
         }
     }
 }
?>
				<div class="author-list">
                    <?php 
if ($connected->have_posts()) {
    // Display connected participants
    ?>
                        <?php 
    while ($connected->have_posts()) {
        $connected->the_post();
        ?>
                            <?php 
        $id = get_the_ID();
        $job_title = get_field('job_title', $id);
        $affiliation = get_field('affiliation', $id);
        $separator = $job_title && $affiliation ? ' - ' : '';
        $role = p2p_get_meta(get_post()->p2p_id, 'role', true);
        $comma = $role ? ', ' : '';
        ?>
							<div class="s-author">
								<div class="author-data">
									<div class="author-name">
                                        <a href="<?php 
        echo get_the_permalink($id);
        ?>
"><?php 
        echo get_the_title($id);
        ?>
</a><span class="author-role"><?php 
        echo $comma . $role;
        ?>
</span>
예제 #19
0
 /**
  * Return the available license upgrade paths
  *
  * @return bool|array false if no upgrades, or the array of license upgrades
  */
 function get_upgrade_paths()
 {
     //lazy load the upgrade paths
     if ($this->_upgrade_paths === false) {
         $connected_licenses = get_posts(array('connected_type' => foolic_post_relationships::LICENSE_TO_LICENSE, 'connected_items' => $this->_post, 'connected_direction' => 'to', 'post_count' => -1, 'nopaging' => true, 'post_status' => 'any', 'suppress_filters' => false));
         $this->_upgrade_paths = array();
         if ($connected_licenses) {
             foreach ($connected_licenses as $license) {
                 $this->_upgrade_paths[] = array('name' => p2p_get_meta($license->p2p_id, 'upgrade', true), 'license' => $license);
             }
         }
     }
     return $this->_upgrade_paths;
 }