public function update(Collaboration $collaboration){ $query = $this->_db->prepare( 'UPDATE t_collaboration SET titre=:titre, description=:description, status=:status, duree=:duree, updated=:updated, updatedBy=:updatedBy WHERE id=:id') or die (print_r($this->_db->errorInfo())); $query->bindValue(':id', $collaboration->id()); $query->bindValue(':titre', $collaboration->titre()); $query->bindValue(':description', $collaboration->description()); $query->bindValue(':status', $collaboration->status()); $query->bindValue(':duree', $collaboration->duree()); $query->bindValue(':updated', $collaboration->updated()); $query->bindValue(':updatedBy', $collaboration->updatedBy()); $query->execute(); $query->closeCursor(); }
/** * Merge child posts when merge action initiated. * * @param int $post_id Post ID. */ function maybe_merge_post($post_id) { if (!isset($_GET['merge_noonce']) || !isset($_GET['merge_action'])) { return false; } if ('merge_children' !== $_GET['merge_action']) { } $nonce = $_GET['merge_noonce']; if (!wp_verify_nonce($nonce, 'livepress-merge_post-' . $post_id)) { return false; } // Temporarily remove the edit post filter, so we can update without firing it again. remove_filter('edit_post', array($this, 'maybe_merge_post'), 10); // Merge the child posts $post = LivePress_PF_Updates::get_instance()->merge_children($post_id); // Update the post wp_update_post($post); // Clear the post term cache Collaboration::clear_terms_cache($post_id); // Re-add the edit_post filter. add_filter('edit_post', array($this, 'maybe_merge_post'), 10); return true; }
<?php /** * Story Loop Template * Author: Willem Prins | SOMTIJDS * Project: Tandem * Date created: 10/04/2016 * * @package Exchange Plugin **/ // Exit if accessed directly. if (!defined('ABSPATH')) { exit; } $exchange = new Collaboration($post); ?> <?php include_once get_stylesheet_directory() . '/parts/nav-breadcrumbs-bar.php'; ?> <main id="main" role="main" data-scroll="main"> <div class="main-inner"> <article id="post-<?php the_ID(); ?> " <?php post_class(''); ?>
/** * Install/upgrade required tables * * @todo Remove this. The new table(s) functionality has already been removed. * * @static */ static function install_or_upgrade() { $options = get_option(self::$options_name); if (get_option(self::$options_name . '_version') != LP_PLUGIN_VERSION) { Collaboration::install(); $postUpdater = new LivePress_Administration(); $postUpdater->merge_default_values(); update_option(self::$options_name . '_version', LP_PLUGIN_VERSION); } }
/** * Update the live comment feed section. */ public function update_live_comments() { check_ajax_referer('update_live_comments_nonce'); $post_id = (int) $_POST['post_id']; if (!current_user_can('edit_post', $post_id)) { die; } Collaboration::get_live_edition_data(); die; }
/** * Enable the Real-Time Editor for LivePress. * * Fetch the content of the user's current textarea and return: * - Original post content, split into regions with distinct IDs * - Processed content, again split into regions * - User's POSTed content, split into regions with same IDs as original post * - Processed POSTed content, split into regions */ public function start_editor() { // Globalize $post so we can modify it a bit before using it global $post; // Set up the $post object $post_id = absint($_POST['post_id']); $post = get_post($post_id); $post->no_update_tag = true; if (isset($_POST['content'])) { $user_content = wp_kses_post(stripslashes($_POST['content'])); } else { $user_content = ''; } $this->assemble_pieces($post); // If the post content is not empty, and there are no child posts, the post has // just been made live. Insert the content as a live update if (0 == count($this->pieces)) { if ('' !== $user_content) { // Add a live update with the current content if (array_key_exists('update_meta', $_POST)) { $update_meta = $_POST['update_meta']; } $update_meta['draft'] = false; // TODO: set to match the post state $title = get_the_title($post_id); $update_header = !empty($title) && 'Auto Draft' !== $title ? 'update_header="' . $title . '"' : ''; $user = wp_get_current_user(); $user_text = ' authors="' . $user->display_name . '" ' . $update_header; $user_content = str_replace('authors=""', $user_text, $user_content); $admin_settings = new LivePress_Admin_Settings(); $settings = $admin_settings->get_settings(); if (in_array('AUTHOR', $settings->show)) { $avartar_html = $this->avatar_html($post) . '<div class="livepress-update-inner-wrapper lp_avatar_shown">'; $user_content = str_replace('<div class="livepress-update-inner-wrapper lp_avatar_hidden">', $avartar_html, $user_content); } $this->add_update($post, $user_content, '', $update_meta); $this->assemble_pieces($post); } } $original = $this->pieces; if ($post->post_content == $user_content) { $user = null; } else { // Proceed user-supplied post content. $user = $this->pieces; } $ans = array('orig' => $original, 'user' => $user, 'edit_uuid' => $this->near_uuid, 'editStartup' => Collaboration::return_live_edition_data()); header('Content-type: application/javascript'); echo json_encode($ans); die; }
/** * Enable the Real-Time Editor for LivePress. * * Fetch the content of the user's current textarea and return: * - Original post content, split into regions with distinct IDs * - Processed content, again split into regions * - User's POSTed content, split into regions with same IDs as original post * - Processed POSTed content, split into regions */ public function start_editor() { // Globalize $post so we can modify it a bit before using it global $post; // Set up the $post object $post_id = (int) $_POST['post_id']; $post = get_post($post_id); $post->no_update_tag = true; if (isset($_POST['content'])) { $user_content = wp_kses_post(stripslashes($_POST['content'])); } else { $user_content = ''; } $this->assemble_pieces($post); // If the post content is not empty, and there are no child posts, the post has // just been made live. Insert the content as a live update if (0 == count($this->pieces)) { if ('' !== $user_content) { // Add a live update with the current content $this->add_update($post, $user_content, ''); $this->assemble_pieces($post); } } $original = $this->pieces; if ($post->post_content == $user_content) { $user = null; } else { // Proceed user-supplied post content. $user = $this->pieces; } $ans = array('orig' => $original, 'user' => $user, 'edit_uuid' => $this->near_uuid, 'editStartup' => Collaboration::return_live_edition_data()); header("Content-type: application/javascript"); echo json_encode($ans); die; }
function createCollaboration($collaboration, $url, $image) { global $bdd, $_TABLES; if (!is_null($bdd) && !is_null($_TABLES)) { $objCollaboration = new Collaboration($bdd, $_TABLES); $objCollaboration->createCollaboration($collaboration, $url, $image); } else { error_log("BDD ERROR : " . json_encode($bdd)); error_log("TABLES ERROR : " . json_encode($_TABLES)); } }
<?php if (session_status() == PHP_SESSION_NONE) { session_start(); } require_once dirname(dirname(__FILE__)) . "/common/php/class/class.collaboration.php"; global $bdd; global $_TABLES; $content = ""; if (!is_null($bdd) && !is_null($_TABLES)) { $objCollaboration = new Collaboration($bdd, $_TABLES); $collaborations = $objCollaboration->getAllCollaborations(); if ($collaborations) { $view = new Template(dirname(__FILE__) . '/html/collaboration.html'); foreach ($collaborations as $key => $value) { $content .= $view->getView(array("title" => $value->collaboration, "url" => $value->url, "image" => $value->image)); } echo $content; } else { // 404 echo "404 Not Found"; } } else { error_log("BDD ERROR : " . json_encode($bdd)); error_log("TABLES ERROR : " . json_encode($_TABLES)); }