Esempio n. 1
0
****************************************************************************/
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'm_delete') {
        if (!empty($_REQUEST['delete_posts']) && is_array($_REQUEST['delete_posts'])) {
            foreach ($_REQUEST['delete_posts'] as $p_id => $v) {
                fn_discussion_delete_post($p_id);
            }
        }
    }
    if ($mode == 'delete') {
        if (!empty($_REQUEST['post_id'])) {
            fn_discussion_delete_post($_REQUEST['post_id']);
        }
    }
    return array(CONTROLLER_STATUS_OK);
}
if ($mode == 'update') {
    $discussion = array();
    if (!empty($_REQUEST['discussion_type'])) {
        $discussion = fn_get_discussion(0, $_REQUEST['discussion_type'], true, $_REQUEST);
    }
    if (!empty($discussion) && $discussion['type'] != 'D' && Registry::ifGet('addons.discussion.home_page_testimonials', 'N') != 'D') {
        if (fn_allowed_for('MULTIVENDOR') || fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) {
            Registry::set('navigation.tabs.discussion', array('title' => __('discussion_title_home_page'), 'js' => true));
        }
    } else {
        $discussion['is_empty'] = true;
Esempio n. 2
0
 public function delete($id)
 {
     if (fn_allowed_for('MULTIVENDOR') && $this->auth['user_type'] == 'V') {
         return array('status' => Response::STATUS_FORBIDDEN);
     }
     $status = Response::STATUS_NOT_FOUND;
     $data = array();
     $params = array();
     if ($this->getParentName() == 'products') {
         $parent_product = $this->getParentData();
         $params['object_id'] = $parent_product['product_id'];
         $params['object_type'] = 'P';
     }
     if ($this->getPost($id, $params)) {
         fn_discussion_delete_post($id);
         $status = Response::STATUS_NO_CONTENT;
     }
     return array('status' => $status, 'data' => $data);
 }