本文整理汇总了PHP中tmsModel::getTable方法的典型用法代码示例。如果您正苦于以下问题:PHP tmsModel::getTable方法的具体用法?PHP tmsModel::getTable怎么用?PHP tmsModel::getTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tmsModel
的用法示例。
在下文中一共展示了tmsModel::getTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteCart
public function deleteCart()
{
$model = new tmsModel();
$carts = $model->getTable('carts');
if (!empty($this->virtuemart_cart_id)) {
$carts->delete($this->virtuemart_cart_id, 'virtuemart_cart_id');
} else {
$currentUser = JFactory::getUser();
if (!empty($currentUser->id)) {
$carts->delete($currentUser->id);
}
}
}
示例2: saveRating
/**
* Save a rating
* @author Max Milbers
*/
public function saveRating($data = 0)
{
//Check user_rating
$maxrating = tsmConfig::get('vm_maximum_rating_scale', 5);
$tsmart_product_id = vRequest::getInt('tsmart_product_id', 0);
$app = JFactory::getApplication();
if ($app->isSite()) {
$user = JFactory::getUser();
$userId = $user->id;
$allowReview = $this->allowReview($tsmart_product_id);
$allowRating = $this->allowRating($tsmart_product_id);
} else {
$userId = $data['created_by'];
$allowReview = true;
$allowRating = true;
}
if (!empty($tsmart_product_id)) {
//if ( !empty($data['tsmart_product_id']) && !empty($userId)){
if (empty($data)) {
$data = vRequest::getPost();
}
if ($allowRating) {
//normalize the rating
if ($data['vote'] < 0) {
$data['vote'] = 0;
}
if ($data['vote'] > $maxrating + 1) {
$data['vote'] = $maxrating;
}
$data['lastip'] = $_SERVER['REMOTE_ADDR'];
$data['vote'] = (int) $data['vote'];
$rating = $this->getRatingByProduct($data['tsmart_product_id']);
vmdebug('$rating', $rating);
$vote = $this->getVoteByProduct($data['tsmart_product_id'], $userId);
vmdebug('$vote', $vote);
$data['tsmart_rating_vote_id'] = empty($vote->tsmart_rating_vote_id) ? 0 : $vote->tsmart_rating_vote_id;
if (isset($data['vote'])) {
$votesTable = $this->getTable('rating_votes');
$res = $votesTable->bindChecknStore($data, TRUE);
if (!$res) {
vmError(get_class($this) . '::Error store votes ');
}
}
if (!empty($rating->rates) && empty($vote)) {
$data['rates'] = $rating->rates + $data['vote'];
$data['ratingcount'] = $rating->ratingcount + 1;
} else {
if (!empty($rating->rates) && !empty($vote->vote)) {
$data['rates'] = $rating->rates - $vote->vote + $data['vote'];
$data['ratingcount'] = $rating->ratingcount;
} else {
$data['rates'] = $data['vote'];
$data['ratingcount'] = 1;
}
}
if (empty($data['rates']) || empty($data['ratingcount'])) {
$data['rating'] = 0;
} else {
$data['rating'] = $data['rates'] / $data['ratingcount'];
}
$data['tsmart_rating_id'] = empty($rating->tsmart_rating_id) ? 0 : $rating->tsmart_rating_id;
vmdebug('saveRating $data', $data);
$rating = $this->getTable('ratings');
$res = $rating->bindChecknStore($data, TRUE);
if (!$res) {
vmError(get_class($this) . '::Error store rating ');
}
}
if ($allowReview and !empty($data['comment'])) {
//if(!empty($data['comment'])){
$data['comment'] = substr($data['comment'], 0, tsmConfig::get('vm_reviews_maximum_comment_length', 2000));
// no HTML TAGS but permit all alphabet
$value = preg_replace('@<[\\/\\!]*?[^<>]*?>@si', '', $data['comment']);
//remove all html tags
$value = (string) preg_replace('#on[a-z](.+?)\\)#si', '', $value);
//replace start of script onclick() onload()...
$value = trim(str_replace('"', ' ', $value), "'");
$data['comment'] = (string) preg_replace('#^\'#si', '', $value);
//replace ' at start
$data['comment'] = nl2br($data['comment']);
// keep returns
//set to defaut value not used (prevent hack)
$data['review_ok'] = 0;
$data['review_rating'] = 0;
$data['review_editable'] = 0;
// Check if ratings are auto-published (set to 0 prevent injected by user)
//
$app = JFactory::getApplication();
if ($app->isSite()) {
if (tsmConfig::get('reviews_autopublish', 1)) {
$data['published'] = 1;
} else {
$model = new tmsModel();
$product = $model->getTable('products');
$product->load($data['tsmart_product_id']);
$vendorId = vmAccess::isSuperVendor();
//.........这里部分代码省略.........