public function save(WpProQuiz_Model_Category $category) { $type = $category->getType(); if ($category->getCategoryId() == 0) { $this->_wpdb->insert($this->_tableCategory, array('category_name' => $category->getCategoryName(), 'type' => empty($type) ? 'QUESTION' : $type), array('%s', '%s')); $category->setCategoryId($this->_wpdb->insert_id); } else { $this->_wpdb->update($this->_tableCategory, array('category_name' => $category->getCategoryName()), array('category_id' => $category->getCategoryId()), array('%s'), array('%d')); } return $category; }
public static function ajaxDeleteCategory($data, $func) { if (!current_user_can('wpProQuiz_edit_quiz')) { return json_encode(array()); } $categoryMapper = new WpProQuiz_Model_CategoryMapper(); $category = new WpProQuiz_Model_Category($data); $categoryMapper->delete($category->getCategoryId()); return json_encode(array()); }