本文整理汇总了PHP中cmsFramework::getCustomToken方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsFramework::getCustomToken方法的具体用法?PHP cmsFramework::getCustomToken怎么用?PHP cmsFramework::getCustomToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsFramework
的用法示例。
在下文中一共展示了cmsFramework::getCustomToken方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _delete
function _delete()
{
$this->Discussion->data =& $this->params;
if ($post_id = Sanitize::getInt($this->params, 'post_id')) {
$owner_id = $this->Discussion->getPostOwner($post_id);
$token = Sanitize::getString($this->params, 'token');
if (!$this->Access->canDeletePost($owner_id) || 0 != strcmp($token, cmsFramework::getCustomToken($post_id))) {
return $this->ajaxError(s2Messages::accessDenied());
}
if ($this->Discussion->delete('discussion_id', $post_id)) {
return $this->ajaxUpdatePage("jr_post{$post_id}", __t("The comment has been removed.", true));
}
}
return $this->ajaxError(__t("There was a problem removing the comment.", true, true));
}
示例2: _save
function _save()
{
$response = array();
$formToken = cmsFramework::getCustomToken($this->review_id);
if ($this->denyAccess == true || !Sanitize::getString($this->params['form'], $formToken)) {
return $this->ajaxError(s2Messages::accessDenied());
}
# Validate form token
$this->components = array('security');
$this->__initComponents();
if ($this->invalidToken) {
return $this->ajaxError(s2messages::invalidToken());
}
// Check if an owner reply already exists
$this->OwnerReply->fields = array();
if ($reply = $this->OwnerReply->findRow(array('fields' => array('OwnerReply.owner_reply_text', 'OwnerReply.owner_reply_approved'), 'conditions' => array('OwnerReply.id = ' . $this->review_id)))) {
if ($reply['OwnerReply']['owner_reply_approved'] == 1) {
$error_text = __t("A reply for this review already exists.", true);
$response[] = "jQuery('#jr_ownerReplyLink{$this->review_id}').remove();";
return $this->ajaxError($error_text, $response);
}
}
if ($this->Config->owner_replies) {
if ($this->data['OwnerReply']['owner_reply_text'] != '' && $this->data['OwnerReply']['id'] > 0) {
$this->data['OwnerReply']['owner_reply_created'] = date('Y-m-d H:i:s');
$this->data['OwnerReply']['owner_reply_approved'] = 1;
// Replies will be moderated by default
if ($this->OwnerReply->store($this->data)) {
$update_text = $this->data['OwnerReply']['owner_reply_approved'] ? __t("Your reply was submitted and has been approved.", true) : __t("Your reply was submitted and will be published once it is verified.", true);
$response[] = "jQuery('#jr_ownerReplyLink{$this->review_id}').remove();";
return $this->ajaxUpdateDialog($update_text, $response);
}
return $this->ajaxError(s2Messages::submitErrorDb());
}
# Validation failed
if (isset($this->Security)) {
$reponse[] = "jQuery('s2Token').val('" . $this->Security->reissueToken() . "')";
}
return $this->ajaxValidation(__t("The reply is empty.", true), $response);
}
}
示例3: _save
function _save()
{
$response = array();
$this->data['Vote']['user_id'] = $this->_user->id;
$this->data['Vote']['review_id'] = (int) $this->data['Vote']['review_id'];
# Exact vote check to prevent form tampering. User can cheat the js and enter any interger, thus increasing the count
$this->data['Vote']['vote_yes'] = Sanitize::getInt($this->data['Vote'], 'vote_yes') ? 1 : 0;
$this->data['Vote']['vote_no'] = Sanitize::getInt($this->data['Vote'], 'vote_no') ? 1 : 0;
$this->data['Vote']['created'] = gmdate('Y-m-d H:i:s');
$this->data['Vote']['ipaddress'] = $this->ipaddress;
if (!$this->data['Vote']['review_id']) {
return $this->ajaxError(s2Messages::submitErrorGeneric());
}
// Find duplicates
$duplicate = $this->Vote->findCount(array('conditions' => array('review_id = ' . $this->data['Vote']['review_id'], 'ipaddress = ' . $this->Vote->Quote($this->data['Vote']['ipaddress']))));
// It's a guest so we only care about checking the IP address if this feature is not disabled and
// server is not localhost
if (!$this->_user->id) {
if (!$this->Config->vote_ipcheck_disable && $this->ipaddress != '127.0.0.1') {
// Do the ip address check everywhere except in localhost
$duplicate = $this->Vote->findCount(array('conditions' => array('review_id = ' . $this->data['Vote']['review_id'], 'ipaddress = ' . $this->Vote->Quote($this->ipaddress))));
}
} else {
$duplicate = $this->Vote->findCount(array('conditions' => array('review_id = ' . $this->data['Vote']['review_id'], "(user_id = {$this->_user->id}" . ($this->ipaddress != '127.0.0.1' && !$this->Config->vote_ipcheck_disable ? " OR ipaddress = " . $this->Vote->Quote($this->ipaddress) . ") " : ')'))));
}
if ($duplicate > 0) {
# Hides vote buttons and shows message alert
$response[] = "jQuery('#jr_reviewVote{$this->data['Vote']['review_id']}').fadeOut('medium',function(){\n jQuery(this).html('" . __t("You already voted.", true, true) . "').fadeIn();\n });";
return $this->ajaxResponse($response);
}
if ($this->Vote->store($this->data)) {
# Hides vote buttons and shows message alert
$response[] = "jQuery('#jr_reviewVote{$this->data['Vote']['review_id']}').fadeOut('medium',function(){\n jQuery(this).html('" . __t("Thank you for your vote.", true, true) . "').fadeIn();\n });";
# Facebook wall integration only for positive votes
$facebook_integration = Sanitize::getBool($this->Config, 'facebook_enable') && Sanitize::getBool($this->Config, 'facebook_votes');
$token = cmsFramework::getCustomToken($this->data['Vote']['review_id']);
$facebook_integration and $this->data['Vote']['vote_yes'] and $response[] = "\n jQuery.ajax({url:s2AjaxUri+jreviews.ajax_params()+'&url=facebook/_postVote/id:{$this->data['Vote']['review_id']}&{$token}=1',dataType:'script'});\n ";
return $this->ajaxResponse($response);
}
return $this->ajaxError(s2Messages::submitErrorDb());
}
示例4: _save
//.........这里部分代码省略.........
$ratingErr = $criteria_qty;
} else {
for ($i = 0; $i < $criteria_qty; $i++) {
if (!isset($this->data['Rating']['ratings'][$i]) || (empty($this->data['Rating']['ratings'][$i]) || $this->data['Rating']['ratings'][$i] == 'undefined' || (double) $this->data['Rating']['ratings'][$i] > $this->Config->rating_scale)) {
$ratingErr++;
}
}
}
$this->Review->validateInput('', "rating", "text", sprintf(__t("You are missing a rating in %s criteria.", true), $ratingErr), $ratingErr);
}
# Validate custom fields
$review_valid_fields = $this->Field->validate($this->data, 'review', $this->Access);
$this->Review->validateErrors = array_merge($this->Review->validateErrors, $this->Field->validateErrors);
$this->Review->validateInput($this->data['Review']['comments'], "comments", "text", __t("You must fill in your comment.", true), $this->Config->reviewform_comment == 'required' ? true : false);
# Validate security code
if ($isNew && $this->Access->showCaptcha()) {
if (!isset($this->data['Captcha']['code'])) {
$this->Review->validateSetError("code", __t("The security code you entered was invalid.", true));
} elseif ($this->data['Captcha']['code'] == '') {
$this->Review->validateInput($this->data['Captcha']['code'], "code", "text", __t("You must fill in the security code.", true), 1);
} else {
if (!$this->Captcha->checkCode($this->data['Captcha']['code'], $this->ipaddress)) {
$this->Review->validateSetError("code", __t("The security code you entered was invalid.", true));
}
}
}
# Process validation errors
$validation = $this->Review->validateGetErrorArray();
if (!empty($validation)) {
if ($isNew && $this->Access->showCaptcha()) {
// Replace captcha with new instance
$captcha = $this->Captcha->displayCode();
$response[] = "jQuery('.jr_captcha').find('img').attr('src','{$captcha['src']}');";
$response[] = "jQuery('.jr_captcha_code').val('');";
}
return $this->ajaxValidation(implode('<br />', $validation), $response);
}
$savedReview = $this->Review->save($this->data, $this->Access, $review_valid_fields);
$review_id = $this->data['Review']['id'];
// Error on review save
if (Sanitize::getString($savedReview, 'err')) {
return $this->ajaxError($savedReview['err']);
}
// Process moderated actions
if ($isNew && $this->Access->moderateReview() && !$this->data['Review']['author'] || !$isNew && ($this->Config->moderation_review_edit && $this->Access->moderateReview()) && !$this->data['Review']['author'] || $isNew && $this->Config->moderation_editor_reviews && $this->data['Review']['author'] || !$isNew && ($this->Config->moderation_editor_review_edit && $this->Config->moderation_editor_reviews && $this->Access->moderateReview()) && $this->data['Review']['author']) {
$target_id = $isNew ? 'jr_review0Form' : 'jr_review_' . $review_id;
$update_text = __t("Thank you for your submission. It will be published once it is verified.", true);
return $this->ajaxUpdatePage($target_id, $update_text, '');
}
// Get updated review info for non-moderated actions and plugin callback
$fields = array('Criteria.id AS `Criteria.criteria_id`', 'Criteria.criteria AS `Criteria.criteria`', 'Criteria.state AS `Criteria.state`', 'Criteria.tooltips AS `Criteria.tooltips`', 'Criteria.weights AS `Criteria.weights`');
$joins = $this->Listing->joinsReviews;
// Triggers the afterFind in the Observer Model
$this->EverywhereAfterFind = true;
if (isset($this->viewVars['reviews'])) {
$review = current($this->viewVars['reviews']);
} else {
$this->Review->runProcessRatings = true;
$review = $this->Review->findRow(array('fields' => $fields, 'conditions' => 'Review.id = ' . $this->data['Review']['id'], 'joins' => $joins), array('afterFind'));
}
$this->set(array('reviewType' => 'user', 'User' => $this->_user, 'Access' => $this->Access, 'reviews' => array($review['Review']['review_id'] => $review)));
$response = array();
$fb_checkbox = Sanitize::getBool($this->data, 'fb_publish');
$facebook_integration = Sanitize::getBool($this->Config, 'facebook_enable') && Sanitize::getBool($this->Config, 'facebook_reviews') && $fb_checkbox;
// Process non moderated actions
# New user review
if ($isNew && !$this->data['Review']['author']) {
$remove_class = true;
$target_id = 'jr_user_reviews';
$update_text = __t("Thank you for your submission.", true);
$update_html = $this->render('reviews', 'reviews');
# Facebook wall integration
$token = cmsFramework::getCustomToken($review['Review']['review_id']);
$facebook_integration and $response[] = "\n jQuery.get(s2AjaxUri+jreviews.ajax_params()+'&url=facebook/_postReview/id:{$review['Review']['review_id']}&{$token}=1');\n ";
return $this->ajaxUpdatePage($target_id, $update_text, $update_html, compact('response', 'remove_class'));
}
# Edited user review
if (!$isNew && !$this->data['Review']['author']) {
// Setup vars for post submit effects
$target_id = 'jr_review_' . $review_id;
$update_text = __t("Your changes were saved.", true);
$update_html = $this->render('reviews', 'reviews');
return $this->ajaxUpdatePage($target_id, $update_text, $update_html);
}
# New editor review
if ($isNew && $this->data['Review']['author']) {
$target_id = 'jr_review_' . $review_id;
$update_text = Sanitize::getInt($review['Criteria'], 'state') != 2 ? __t("Thank you for your submission. Refresh the page to see your review.", true) : __t("Thank you for your submission. Refresh the page to see your comment.", true);
# Facebook wall integration
$token = cmsFramework::getCustomToken($review['Review']['review_id']);
$facebook_integration and $response[] = "\n jQuery.get(s2AjaxUri+jreviews.ajax_params()+'&url=facebook/_postReview/id:{$review['Review']['review_id']}&{$token}=1');\n ";
return $this->ajaxUpdatePage($target_id, $update_text, '', compact('response'));
}
# Edited editor review
if (!$isNew && $this->data['Review']['author']) {
$target_id = 'jr_review_' . $review_id;
$update_text = __t("Your changes were saved, refresh the page to see them.", true);
return $this->ajaxUpdatePage($target_id, $update_text);
}
}
示例5: listingManager
function listingManager($listing)
{
$canEdit = $this->Access->canEditListing($listing['Listing']['user_id']);
$canPublish = $this->Access->canPublishListing($listing['Listing']['user_id']);
$canDelete = $this->Access->canDeleteListing($listing['Listing']['user_id']);
$isManager = $this->Access->isManager();
$listing_id = $listing['Listing']['listing_id'];
$formToken = cmsFramework::getCustomToken($listing_id);
$canOrder = false;
if ($this->Paid && $this->Paid->canOrder($listing)) {
$canOrder = $this->PaidRoutes->getPaymentLink($listing, array('lazy_load' => true));
}
if ($canEdit || $canPublish || $canDelete || $isManager || $canOrder) {
?>
<span class="jrManagement jrButton"><?php
__t("Manage");
?>
<span class="jrArrowBottom"></span>
<?php
if ($canOrder) {
// Load assets for paid listings onclick
?>
<script type="text/javascript">
/* <![CDATA[ */
function jr_paidLoadScript(afterLoad)
{
if(jQuery('body').data('jrOrderAssets') == true)
{
if(undefined!=afterLoad) afterLoad();
} else {
jQuery.getScript('<?php
echo $this->locateScript('paidlistings');
?>
',function(){
jQuery.getCSS("<?php
echo pathToUrl($this->locateThemeFile('theme_css', 'paidlistings', '.css'));
?>
",function()
{
jQuery('body').data('jrOrderAssets',true);
if(afterLoad!=undefined) afterLoad();
});
});
}
};
/* ]]> */
</script>
<?php
}
?>
<div id="jr_listing_manager<?php
echo $listing_id;
?>
" class="jrManager">
<ul class="jrManagementLinks">
<?php
if ($canOrder) {
?>
<li>
<?php
echo $canOrder;
?>
</li>
<?php
}
?>
<?php
if ($canEdit) {
?>
<li>
<span class="jrIcon jrIconEdit"></span>
<?php
echo $this->Routes->listingEdit(__t("Edit", true), $listing, array('class' => 'jr_edit'));
?>
</li>
<?php
}
?>
<?php
if ($canPublish) {
?>
<li>
<span class="jrIcon <?php
echo $listing['Listing']['state'] ? 'jrIconYes' : 'jrIconDisabled';
?>
"></span>
<a href="#publish" id="jr_publishLink<?php
echo $listing_id;
?>
" class="<?php
echo $listing['Listing']['state'] ? 'jr_published' : 'jr_unpublished';
?>
" onclick="jreviews.listing.publish(this,{'token':'<?php
//.........这里部分代码省略.........
示例6: _save
//.........这里部分代码省略.........
$currImages = $this->Uploads->images;
}
$this->data['Listing']['images'] = implode("\n", $currImages);
}
# Save listing
$savedListing = $this->Listing->store($this->data);
$listing_id = $this->data['Listing']['id'];
if (!$savedListing) {
$validation .= __t("The was a problem saving the listing", true, true);
}
// Error on listing save
if ($validation != '') {
$response[] = "{$parentFrame}.jQuery('#jr_listingFormValidation').html('{$validation}');";
$response[] = "{$parentFrame}.jQuery('.button').removeAttr('disabled');";
$response[] = "{$parentFrame}.jQuery('.jr_loadingSmall').hide();";
return $this->makeJS($response);
}
# Save listing custom fields
$this->data['Field']['Listing']['contentid'] = $this->data['Listing']['id'];
$this->Field->save($this->data, 'listing', $isNew, $listing_valid_fields);
# Begin insert review in table
if ($revFormEnabled && $criteria['Criteria']['state']) {
// Get reviewer type, for now editor reviews don't work in Everywhere components
$this->data['Review']['author'] = (int) $this->Access->isJreviewsEditor($this->_user->id);
$this->data['Review']['mode'] = 'com_content';
$this->data['Review']['pid'] = (int) $this->data['Listing']['id'];
// Force plugin loading on Review model
$this->_initPlugins('Review');
$this->Review->isNew = true;
$savedReview = $this->Review->save($this->data, $this->Access, $review_valid_fields);
}
# Before render callback
if ($isNew && isset($this->Listing->plgBeforeRenderListingSaveTrigger)) {
$plgBeforeRenderListingSave = $this->Listing->plgBeforeRenderListingSave();
switch ($plgBeforeRenderListingSave) {
case '0':
$this->data['Listing']['state'] = 1;
break;
case '1':
$this->data['Listing']['state'] = 0;
break;
case '':
break;
default:
return $plgBeforeRenderListingSave;
break;
}
}
# Moderation disabled
if (!isset($this->data['Listing']['state']) || $this->data['Listing']['state']) {
$fields = array('Criteria.criteria AS `Criteria.criteria`', 'Criteria.tooltips AS `Criteria.tooltips`');
$listing = $this->Listing->findRow(array('fields' => $fields, 'conditions' => array('Listing.id = ' . $listing_id)), array('afterFind'));
# Facebook wall integration
$fb_checkbox = Sanitize::getBool($this->data, 'fb_publish');
$facebook_integration = Sanitize::getBool($this->Config, 'facebook_enable') && Sanitize::getBool($this->Config, 'facebook_listings') && $fb_checkbox;
$token = cmsFramework::getCustomToken($listing_id);
$facebook_integration and $response[] = $parentFrame . '.jQuery.get(' . $parentFrame . '.s2AjaxUri+' . $parentFrame . '.jreviews.ajax_params()+\'&url=facebook/_postListing/id:' . $listing_id . '&' . $token . '=1\');
';
$url = cmsFramework::route($listing['Listing']['url']);
$update_text = $isNew ? __t("Thank you for your submission.", true, true) : __t("The listing was successfully saved.", true, true);
//JOEYG CODE
//THE FOLLOWING GETS THE LISTING TYPE FROM THE DB FOR THE NEWLY SAVED LISTING
//IF THE TYPE IS BUSINESS PROFILE OR PROJECT LISTING THEN DISPLAY THE after_submit.thtml file
//ELSE DISPLAY NORMAL MESSAGE
//IF WE ONLY WANT TO ADD THE after_submit.thtml if the listing is new then add
if ($isNew) {
$query = "SELECT `listing_type` FROM `jos_vpbd_content_criteria` WHERE `jos_vpbd_content_criteria`.`listing_id` = " . $this->data['Listing']['id'];
$this->_db->setQuery($query);
$jg_listing_type = $this->_db->loadResult();
if ($jg_listing_type == 2 || $jg_listing_type == 7) {
$update_html = $this->render('listings', 'after_submit');
} else {
$update_html = "<a href=\"{$url}\">" . __t("Click here to view your listing", true) . "</a>";
}
//ends if/else
} else {
//not new
$update_html = "<a href=\"{$url}\">" . __t("Click here to view your listing", true) . "</a>";
}
//ends if($isNew)
//ENDS JOEYG ALTER CODE
$jsonObject = json_encode(compact('target_id', 'update_text', 'update_html'));
$response[] = '
var $parentForm = ' . $parentFrame . '.jQuery(\'#jr_listingForm\');
$parentForm.scrollTo({duration:400,offset:-100});
$parentForm.s2ShowUpdate(' . $jsonObject . ');
';
return $this->makeJS($response);
}
# Moderation enabled
$update_text = __t("Thank you for your submission. It will be published once it is verified.", true);
$update_html = '<div id=\\"s2Msgjr_listingForm\\" class=\\"jr_postUpdate\\">' . $update_text . '</div>';
$response[] = '
var $parentForm = ' . $parentFrame . '.jQuery(\'#jr_listingForm\');
$parentForm.scrollTo({duration:400,offset:-100},function(){
$parentForm.fadeOut(250,function(){$parentForm.html("' . $update_html . '").show();});
});
';
return $this->makeJS($response);
}
示例7: formIntegrityToken
function formIntegrityToken($entry, $keys, $input = true)
{
$string = '';
!isset($entry['form']) and $entry['form'] = array();
!isset($entry['data']) and $entry['data'] = array();
unset($entry['data']['controller'], $entry['data']['action'], $entry['data']['module']);
foreach ($keys as $key) {
if (isset($entry[$key])) {
$string .= is_array($entry[$key]) ? serialize($entry[$key]) : $entry[$key];
}
}
if ($string == '') {
return '';
}
return $input ? '<input type="hidden" name="' . cmsFramework::getCustomToken($string) . '" value="1" />' : cmsFramework::getCustomToken($string);
}
示例8: _postVote
function _postVote()
{
# Check if FB integration for reviews is enabled
$facebook_integration = Sanitize::getBool($this->Config, 'facebook_enable') && Sanitize::getBool($this->Config, 'facebook_reviews');
if (!$facebook_integration) {
return;
}
$review_id = Sanitize::getInt($this->params, 'id');
# First check - review id
if (!$review_id) {
return;
}
# Stop form data tampering
$formToken = cmsFramework::getCustomToken($review_id);
if (!cmsFramework::isAdmin() && !$this->__validateToken($formToken)) {
return s2Messages::accessDenied();
}
$facebook = $this->_getFBClass();
# Second check - FB session
if ($fbsession = $facebook->getSession()) {
try {
//get user id
$uid = $facebook->getUser();
$user = $facebook->api('/me');
$fql = "SELECT publish_stream FROM permissions WHERE uid = " . $uid;
$param = array('method' => 'fql.query', 'query' => $fql, 'callback' => '');
$fqlResult = $facebook->api($param);
if (!$fqlResult[0]['publish_stream']) {
return false;
} else {
$review = $this->Review->findRow(array('conditions' => array('Review.id = ' . $review_id)), array());
$this->Everywhere->loadListingModel($this, $review['Review']['extension']);
$listing = $this->Listing->findRow(array('conditions' => array('Listing.' . $this->Listing->realKey . ' = ' . $review['Review']['listing_id'])), array('afterFind'));
$listing_url = $this->makeUrl($listing['Listing']['url']);
$review['Review']['comments'] = strip_tags($review['Review']['comments']);
if ($this->Config->facebook_posts_trim >= 0) {
App::import('Helper', 'text', 'jreviews');
$Text = ClassRegistry::getClass('TextHelper');
$review['Review']['comments'] = $Text->truncateWords($review['Review']['comments'], $this->Config->facebook_posts_trim);
}
# Publish stream permission granted so we can post on the user's wall!
# Begin building the stream $fbArray
$fbArray = array();
$fbArray['method'] = 'stream.publish';
$fbArray['message'] = sprintf($this->activities['vote helpful'], $listing['Listing']['title']);
$fbArray['attachment'] = array('name' => $listing['Listing']['title'], 'href' => $listing_url, 'description' => $review['Review']['comments']);
$fbArray['attachment']['properties'][__t("Website", true)] = array('text' => cmsFramework::getConfig('sitename'), 'href' => WWW_ROOT);
$review['Rating']['average_rating'] > 0 and $fbArray['attachment']['properties'][__t("Rating", true)] = sprintf(__t("%s stars", true), round($review['Rating']['average_rating'], 1));
isset($listing['Listing']['images'][0]) and $fbArray['attachment']['media'] = array(array('type' => 'image', 'src' => WWW_ROOT . _JR_WWW_IMAGES . $listing['Listing']['images'][0]['path'], 'href' => $listing_url));
$fbArray['attachment'] = json_encode($fbArray['attachment']);
$fbArray['action_links'] = json_encode(array(array('text' => __t("Read review", true), 'href' => $listing_url)));
$fbArray['comments_xid'] = $listing['Listing']['listing_id'];
if ($this->Config->facebook_optout) {
return "FB.ui(" . json_encode($fbArray) . ")";
}
$fb_update = $facebook->api($fbArray);
return true;
}
} catch (Exception $o) {
// Error reading permissions
return false;
}
}
return false;
}
示例9: formIntegrityToken
function formIntegrityToken($entry, $keys, $input = true)
{
$string = '';
$tokens = array();
!isset($entry['form']) and $entry['form'] = array();
!isset($entry['data']) and $entry['data'] = array();
unset($entry['data']['controller'], $entry['data']['action'], $entry['data']['module'], $entry['data']['__raw']);
// Leave only desired $keys from $entry
$params = array_intersect_key($entry, array_fill_keys($keys, 1));
// Orders the array by keys so the hash will match
ksort($params);
// Remove empty elements and cast all values to strings
foreach ($params as $key => $param) {
if (is_array($param) && !empty($param)) {
$param = is_array($param) ? array_filter($param) : false;
if (!empty($param)) {
$tokens[] = array_map('strval', $param);
}
} elseif (!empty($param)) {
$tokens[] = strval($param);
}
}
sort($tokens);
$string = serialize($tokens);
if ($string == '') {
return '';
}
return $input ? '<input type="hidden" name="' . cmsFramework::getCustomToken($string) . '" value="1" />' : cmsFramework::getCustomToken($string);
}
示例10: getParentCatIds
function getParentCatIds($cat_id)
{
# Check for cached version
$cache_file = 'jreviews_menu_cat_' . cmsFramework::locale() . '_' . cmsFramework::getCustomToken($cat_id);
if (Configure::read('Cache.query') && ($cache = S2Cache::read($cache_file))) {
return $cache['___menu_cat'];
}
$query = "\n (\n SELECT \n ParentCategory.id AS cat_id,\n ParentCategory.lft AS lft\n FROM \n #__categories AS Category, \n #__categories AS ParentCategory\n INNER JOIN\n #__jreviews_categories AS JreviewsCategory ON JreviewsCategory.id = ParentCategory.id\n WHERE \n (\n ParentCategory.id = " . (int) $cat_id . " AND ParentCategory.published = 1\n )\n )\n UNION\n (\n SELECT \n ParentCategory.id AS cat_id,\n ParentCategory.lft AS lft\n FROM\n #__categories AS Category,\n #__categories AS ParentCategory\n INNER JOIN\n #__jreviews_categories AS JreviewsCategory ON JreviewsCategory.id = ParentCategory.id\n WHERE\n ( \n Category.published = 1\n AND Category.lft BETWEEN ParentCategory.lft AND ParentCategory.rgt\n AND Category.id = " . (int) $cat_id . "\n AND ParentCategory.parent_id > 0\n )\n ORDER BY \n Category.lft\n )\n ";
$rows = $this->query($query, 'loadObjectList');
$last = array_shift($rows);
array_push($rows, $last);
Configure::read('Cache.query') and S2Cache::write($cache_file, array('___menu_cat' => $rows));
return $rows;
}
示例11: _delete
function _delete($params)
{
$response = array();
$listing_id = $this->data['Listing']['id'] = Sanitize::getInt($this->params, 'id');
# Stop form data tampering
$formToken = cmsFramework::getCustomToken($listing_id);
if (!$listing_id || !Sanitize::getString($this->params['form'], $formToken)) {
return $this->ajaxError(s2Messages::accessDenied());
}
# Load current listing author id
$query = "SELECT Listing.created_by, Listing.images FROM #__content AS Listing WHERE Listing.id = " . $listing_id;
$this->_db->setQuery($query);
$row = end($this->_db->loadAssocList());
# Check access
if (!$this->Access->canDeleteListing($row['created_by'])) {
return $this->ajaxError(s2Messages::accessDenied());
}
$this->data['Listing']['images'] = $row['images'];
# Delete listing and all associated records and images
if ($this->Listing->delete($this->data)) {
$msg = __t("The listing has been removed.", true);
$response[] = "jQuery('#jr_listing_manager{$listing_id}').hide('fast').html('{$msg}').fadeIn(1000).effect('highlight',{},5000);";
return $this->ajaxResponse($response);
}
return $this->ajaxError(s2Messages::submitErrorDb());
}