function index() { $module_id = Sanitize::getInt($this->params, 'module_id', Sanitize::getInt($this->data, 'module_id')); $this->viewSuffix = Sanitize::getString($this->params['module'], 'tmpl_suffix'); $cache_file = 'modules_totals_' . $module_id . '_' . md5(serialize($this->params['module'])); $page = $this->cached($cache_file); if ($page) { return $page; } // Initialize variables $extension = Sanitize::getString($this->params['module'], 'extension'); // Automagically load and initialize Everywhere Model App::import('Model', 'everywhere_' . $extension, 'jreviews'); $class_name = inflector::camelize('everywhere_' . $extension) . 'Model'; $conditions_reviews = array('Review.published = 1'); $extension == 'com_content' and $conditions_listings = array('Listing.state = 1'); $extension != '' and $conditions_reviews[] = "Review.mode = " . $this->quote($extension); if (class_exists($class_name)) { $this->Listing = new $class_name(); $this->Listing->_user = $this->_user; $listings = $this->Listing->findCount(array('conditions' => $conditions_listings), 'DISTINCT Listing.' . $this->Listing->realKey); $reviews = $this->Review->findCount(array('conditions' => $conditions_reviews), 'DISTINCT Review.id'); } # Send variables to view template $this->set(array('listing_count' => isset($listings) ? $listings : 0, 'review_count' => isset($reviews) ? $reviews : 0)); $page = $this->render('modules', 'totals'); # Save cached version $this->cacheView('modules', 'totals', $cache_file, $page); return $page; }
function google($address) { $this->_API['google'] = str_replace('{google_url}', Sanitize::getString($this->Config, 'geomaps.google_url', 'http://maps.google.com'), $this->_API['google']); $geoData = false; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, sprintf($this->_API['google'], urlencode($address))); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = trim(curl_exec($curl)); // Process JSON if (!empty($response)) { $data = json_decode($response); if ($data->status == "OK" && is_array($data->results) && ($result = $data->results[0])) { $status = 200; $elev = 0; $lat = $result->geometry->location->lat; $lon = $result->geometry->location->lng; if (!is_numeric($lat) || !is_numeric($lon)) { $status = 'error'; } $geoData = array('status' => $status, 'lon' => $lon, 'lat' => $lat, 'elev' => $elev); } } curl_close($curl); return $geoData; }
function google($address) { $this->_API['google'] = str_replace('{google_url}', Sanitize::getString($this->Config, 'geomaps.google_url', 'http://maps.google.com'), $this->_API['google']); $geoData = false; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, sprintf($this->_API['google'], urlencode($address))); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $response = trim(curl_exec($curl)); // Process CSV if ($response != '' && $response != 620 && count(explode(',', $response)) > 3) { // Split pieces of data by the comma that separates them list($status, $elev, $lat, $lon) = explode(",", $response); if (!is_numeric($lat) || !is_numeric($lon)) { $status = 'error'; } $geoData = array('status' => $status, 'lon' => $lon, 'lat' => $lat, 'elev' => $elev); // More complete data can be found via XML // Create SimpleXML object from XML Content // $xmlObject = simplexml_load_string($xmlContent); // $localObject = $xmlObject->Response; // prx($localObject); } curl_close($curl); return $geoData; }
function findChildOptions() { $response = array(); $childField = Sanitize::getString($this->data, 'childField'); $childSelected = Sanitize::getString($this->data, 'childSelected'); $parentValue = Sanitize::getString($this->data, 'parentValue'); $module_id = Sanitize::getInt($this->data, 'module_id'); if ($parentValue == '') { $ret = '<option value="">' . __t("Select", true, true) . '</option>'; $response[] = "jQuery(\"#{$childField}{$module_id}\").html('{$ret}').attr('disabled','disabled');"; return implode(' ', $response); } $query = " \r\n SELECT \r\n FieldOption.optionid, FieldOption.text, FieldOption.value\r\n FROM #__jreviews_fieldoptions AS FieldOption\r\n INNER JOIN #__jreviews_fields AS Field ON FieldOption.fieldid = Field.fieldid AND Field.name = '" . $childField . "'\r\n WHERE FieldOption.value LIKE '" . $parentValue . "-%'\r\n "; $this->_db->setQuery($query); $options = $this->_db->loadAssocList(); $ret = '<option value="">' . __t("Select", true, true) . '</option>'; foreach ($options as $option) { if ($childSelected != '' && $option['value'] == $childSelected) { $ret .= '<option selected="selected" value="' . $option['value'] . '">' . $option['text'] . '</option>'; } else { $ret .= '<option value="' . $option['value'] . '">' . $option['text'] . '</option>'; } } $response[] = "jQuery(\"#{$childField}{$module_id}\").html('{$ret}').removeAttr('disabled');"; return implode(' ', $response); }
function addPagination($page, $limit) { if (cmsFramework::isAdmin()) { $url = rtrim($this->base_url, '/') . ($page > 1 ? '/' . 'page' . _PARAM_CHAR . $page . '/limit' . _PARAM_CHAR . $limit . '/' : ''); } else { $order = Sanitize::getString($this->params, 'order'); $default_limit = Sanitize::getInt($this->params, 'default_limit'); $url_params = $this->passedArgs; unset($url_params['page'], $url_params['Itemid'], $url_params['option'], $url_params['view']); if ($page == 1 && $this->limit == $default_limit && ($order == '' || $order == Sanitize::getString($this->params, 'default_order')) && empty($url_params)) { preg_match('/^index.php\\?option=com_jreviews&Itemid=[0-9]+/i', $this->base_url, $matches); $url = $matches[0]; } else { $url = $this->base_url; $page > 1 and $url = rtrim($url, '/') . '/' . 'page' . _PARAM_CHAR . $page . '/'; if ($this->limit != $default_limit) { $url = rtrim($url, '/') . '/limit' . _PARAM_CHAR . $limit . '/'; } } // Remove menu segment from url if page 1 and it' a menu if ($page == 1 && preg_match('/^(index.php\\?option=com_jreviews&Itemid=[0-9]+)(&url=menu\\/)$/i', $url, $matches)) { $url = $matches[1]; } $url = cmsFramework::route($url); } return $url; }
function index($params) { $this->action = 'directory'; // Set view file # Read module params $dir_id = cleanIntegerCommaList(Sanitize::getString($this->params['module'], 'dir_ids')); $conditions = array(); $order = array(); $cat_id = ''; $section_id = ''; $directories = $this->Directory->getTree($dir_id, true); if ($menu_id = Sanitize::getInt($this->params, 'Itemid')) { $menuParams = $this->Menu->getMenuParams($menu_id); } # Category auto detect $ids = CommonController::_discoverIDs($this); extract($ids); if ($cat_id != '' && $section_id == '') { $cat_id = cleanIntegerCommaList($cat_id); $sql = "SELECT section FROM #__categories WHERE id IN (" . $cat_id . ")"; $this->_db->setQuery($sql); $section_id = $this->_db->loadResult(); } $this->set(array('directories' => $directories, 'cat_id' => is_numeric($cat_id) && $cat_id > 0 ? $cat_id : false, 'section_id' => $section_id)); return $this->render('modules', 'directories'); }
function saveFeed($filename = "", $view) { if (Sanitize::getString($this->params, 'action') != 'xml') { return false; } $type = '.' . Sanitize::getString($this->params, 'type', 'rss2'); $App =& App::getInstance(); if (!isset($App->jreviewsPaths['Theme'][$this->c->viewTheme][$this->layout][$view . $type . '.thtml']) && !isset($App->jreviewsPaths['Theme']['default'][$this->layout][$view . $type . '.thtml'])) { return false; } $this->c->autoLayout = false; $this->c->autoRender = false; $rss = array('title' => $this->c->Config->rss_title, 'link' => WWW_ROOT, 'description' => $this->c->Config->rss_description, 'image_url' => WWW_ROOT . "images/stories/" . $this->c->Config->rss_image, 'image_link' => WWW_ROOT); $this->c->set(array('encoding' => $this->encoding, 'rss' => $rss)); $feedFile = fopen($filename, "w+"); if ($feedFile) { $feed = $this->c->render($this->layout, $view . $type); fputs($feedFile, $feed); fclose($feedFile); echo $feed; die; } else { echo "<br /><b>Error creating feed file, please check write permissions.</b><br />"; die; } }
function index($params) { $this->action = 'directory'; // Trigger assets helper method if ($this->_user->id === 0) { $this->cacheAction = Configure::read('Cache.expires'); } $page = array('title' => '', 'show_title' => 0); $conditions = array(); $order = array(); if ($menu_id = Sanitize::getInt($this->params, 'Itemid')) { $menuParams = $this->Menu->getMenuParams($menu_id); $page['title'] = Sanitize::getString($menuParams, 'title'); $page['show_title'] = Sanitize::getString($menuParams, 'dirtitle', 0); } $override_keys = array('dir_show_alphaindex', 'dir_cat_images', 'dir_columns', 'dir_cat_num_entries', 'dir_category_hide_empty', 'dir_category_levels', 'dir_cat_format'); if (Sanitize::getBool($menuParams, 'dir_overrides')) { $overrides = array_intersect_key($menuParams, array_flip($override_keys)); $this->Config->override($overrides); } if ($this->cmsVersion == CMS_JOOMLA15) { $directories = $this->Directory->getTree(Sanitize::getString($this->params, 'dir')); } else { $directories = $this->Category->findTree(array('level' => $this->Config->dir_cat_format === 0 ? 2 : $this->Config->dir_category_levels, 'menu_id' => true, 'dir_id' => Sanitize::getString($this->params, 'dir'), 'pad_char' => '')); } $this->set(array('page' => $page, 'directories' => $directories)); return $this->render('directories', 'directory'); }
function _addOption() { $this->autoRender = false; $this->autoLayout = false; $response = array(); $option = $this->data['FieldOption']['text'] = Sanitize::getString($this->data, 'text'); $value = $this->data['FieldOption']['value'] = Sanitize::stripAll($this->data, 'text'); $fieldid = $this->data['FieldOption']['fieldid'] = Sanitize::getInt($this->data, 'field_id'); $fieldName = Sanitize::getString($this->data, 'name'); // Begin validation if ($value == '') { $validation = __t("The field is empty.", true); $response[] = "jQuery('#jr_fieldOption{$fieldid}').siblings('.jr_loadingSmall').after('<span class=\"jr_validation\"> " . $validation . "</span>');"; return $this->ajaxResponse($response); } // Save $result = $this->FieldOption->save($this->data); switch ($result) { case 'success': // Begin update display $option = $this->data['FieldOption']['text']; $value = $this->data['FieldOption']['value']; $response = "\n jQuery('#{$fieldName}').addOption('{$value}','" . addslashes($option) . "');\n jQuery('#jr_fieldOption{$fieldid}').val(''); \n jQuery('#submitButton{$fieldid}').removeAttr('disabled');\n "; return $this->ajaxResponse($response); case 'duplicate': $validation = sprintf(__t("%s already exists", true), $value); break; case 'db_error': $validation = s2Messages::submitErrorGeneric(); break; } $response[] = "jQuery('#{$fieldName}').selectOptions('" . addslashes($option) . "');"; $response[] = "jQuery('#jr_fieldOption{$fieldid}').siblings('.jr_loadingSmall').after('<span class=\"jr_validation\"> " . $validation . "</span>');"; return $this->ajaxResponse($response); }
function index($params) { /* if($this->_user->id === 0) { $this->cacheAction = Configure::read('Cache.expires'); }*/ $this->action = 'directory'; // Set view file # Read module params $dir_id = isset($this->params['module']) ? cleanIntegerCommaList(Sanitize::getString($this->params['module'], 'dir_ids')) : ''; $conditions = array(); $order = array(); $cat_id = ''; $section_id = ''; if ($this->cmsVersion == CMS_JOOMLA15) { $directories = $this->Directory->getTree($dir_id, true); } else { $directories = $this->Category->findTree(array('level' => $this->Config->dir_category_levels, 'menu_id' => true, 'dir_id' => $dir_id, 'pad_char' => '')); } if ($menu_id = Sanitize::getInt($this->params, 'Itemid')) { $menuParams = $this->Menu->getMenuParams($menu_id); } # Category auto detect $ids = CommonController::_discoverIDs($this); extract($ids); if ($this->cmsVersion == CMS_JOOMLA15 && ($cat_id != '' && $section_id == '')) { $cat_id = cleanIntegerCommaList($cat_id); $sql = "SELECT section FROM #__categories WHERE id IN (" . $cat_id . ")"; $this->_db->setQuery($sql); $section_id = $this->_db->loadResult(); } $this->set(array('directories' => $directories, 'dir_id' => $dir_id, 'cat_id' => is_numeric($cat_id) && $cat_id > 0 ? $cat_id : false, 'section_id' => $section_id)); return $this->render('modules', 'directories'); }
function beforeFilter() { parent::beforeFilter(); $this->viewSuffix = Sanitize::getString($this->params['module'], 'tmpl_suffix'); # Set Theme $this->viewTheme = $this->Config->template; $this->viewImages = S2Paths::get('jreviews', 'S2_THEMES_URL') . $this->viewTheme . _DS . 'theme_images' . _DS; }
function index() { $Session = RegisterClass::getInstance('MvcSession'); $module_id = Sanitize::getInt($this->params, 'module_id', Sanitize::getInt($this->data, 'module_id')); if (!isset($this->params['module'])) { $this->params['module'] = array(); } // For direct calls to the controller if ($this->ajaxRequest) { $this->params = $Session->get('module_params' . $module_id, null, S2Paths::get('jreviews', 'S2_CMSCOMP')); } else { srand((double) microtime() * 1000000); $this->params['rand'] = rand(); $Session->set('module_rand' . $module_id, $this->params['rand'], S2Paths::get('jreviews', 'S2_CMSCOMP')); $Session->set('module_params' . $module_id, $this->params, S2Paths::get('jreviews', 'S2_CMSCOMP')); } $this->viewSuffix = Sanitize::getString($this->params['module'], 'tmpl_suffix'); // Read the module parameters $img_width = Sanitize::getInt($this->params['module'], 'img_width', 50); $random_mode = Sanitize::getString($this->params['module'], 'random_mode', 'Random Users'); $favorites_mode = Sanitize::getString($this->params['module'], 'favorites_mode', 'Other users interested in {title}'); // Pagination $this->Community->limit = $this->module_limit; $this->Community->offset = $this->module_offset; # Get url params for current controller/action $url = Sanitize::getString($_REQUEST, 'url'); $route['url']['url'] = $url; $route['data'] = array(); $route = S2Router::parse($route, true, 'jreviews'); # Check if page is listing detail $detail = Sanitize::getString($route['url'], 'extension', 'com_content') == 'com_content' && isset($route['data']) && Sanitize::getString($route['data'], 'controller') == 'listings' && Sanitize::getString($route['data'], 'action') == 'detail' ? true : false; # Initialize variables $listing_id = $detail ? Sanitize::getInt($route, 'id') : Sanitize::getInt($this->params, 'id'); $option = Sanitize::getString($this->params, 'option'); $view = Sanitize::getString($this->params, 'view'); $task = Sanitize::getString($this->params, 'task'); $listing_title = ''; # Article auto-detect - only for com_content if ($detail || 'com_content' == $option && ('article' == $view || 'view' == $task)) { $query = "SELECT Listing.id, Listing.title FROM #__content AS Listing WHERE Listing.id = " . $listing_id; $this->_db->setQuery($query); $listing = current($this->_db->loadObjectList()); $listing_title = $listing->title; } else { $listing_id = null; } $profiles = $this->Community->getListingFavorites($listing_id, $this->_user->id, $this->params); $total = $this->Community->count; unset($this->Community->count); $this->set(array('profiles' => $profiles, 'listing_title' => $listing_title, 'total' => $total)); $page = $this->render('modules', 'favorite_cbusers'); if ($this->ajaxRequest) { return $this->ajaxResponse($page, false); } else { return $page; } }
function _loadValues() { $field_id = Sanitize::getString($this->data, 'field_id'); $valueq = Sanitize::getString($this->data, 'value'); if ($field_id != '') { $field_options = $this->FieldOption->getControlList($field_id, $valueq); return json_encode($field_options); } }
function reviews() { $access = $this->cmsVersion == CMS_JOOMLA15 ? $this->Access->getAccessId() : $this->Access->getAccessLevels(); $feed_filename = PATH_ROOT . 'cache' . DS . 'jreviewsfeed_' . md5($access . $this->here) . '.xml'; $this->Feeds->useCached($feed_filename, 'reviews'); $extension = Sanitize::getString($this->params, 'extension', 'com_content'); $cat_id = Sanitize::getInt($this->params, 'cat'); $section_id = Sanitize::getInt($this->params, 'section'); $dir_id = Sanitize::getInt($this->params, 'dir'); $listing_id = Sanitize::getInt($this->params, 'id'); $this->encoding = cmsFramework::getCharset(); $feedPage = null; $this->EverywhereAfterFind = true; // Triggers the afterFind in the Observer Model $this->limit = $this->Config->rss_limit; $rss = array('title' => $this->Config->rss_title, 'link' => WWW_ROOT, 'description' => $this->Config->rss_description, 'image_url' => WWW_ROOT . "images/stories/" . $this->Config->rss_image, 'image_link' => WWW_ROOT); $queryData = array('conditions' => array('Review.published = 1', "Review.mode = '{$extension}'"), 'fields' => array('Review.mode AS `Review.extension`'), 'limit' => $this->limit, 'order' => array('Review.created DESC')); if ($extension == 'com_content') { $queryData['conditions'][] = 'Listing.state = 1'; $queryData['conditions'][] = '( Listing.publish_up = "' . NULL_DATE . '" OR Listing.publish_up <= "' . _CURRENT_SERVER_TIME . '" )'; $queryData['conditions'][] = '( Listing.publish_down = "' . NULL_DATE . '" OR Listing.publish_down >= "' . _CURRENT_SERVER_TIME . '" )'; # Shows only links users can access if ($this->cmsVersion == CMS_JOOMLA15) { $access_id = $this->Access->getAccessId(); $queryData['conditions'][] = 'Listing.access <= ' . $access_id; $queryData['conditions'][] = 'Category.access <= ' . $access_id; } else { $cat_id > 0 and $cat_id = array_keys($this->Category->getChildren($cat_id)); $access_id = $this->Access->getAccessLevels(); $queryData['conditions'][] = 'Listing.access IN ( ' . $access_id . ')'; $queryData['conditions'][] = 'Category.access IN ( ' . $access_id . ')'; } } if (!empty($cat_id) && $extension == 'com_content') { // Category feeds only supported for core content $queryData['conditions'][] = 'JreviewsCategory.id IN (' . $this->quote($cat_id) . ')'; $feedPage = 'category'; } elseif ($section_id > 0 && $extension == 'com_content') { $queryData['conditions'][] = 'Listing.sectionid= ' . $section_id; $feedPage = 'section'; } elseif ($dir_id > 0 && $extension == 'com_content') { $queryData['conditions'][] = 'JreviewsCategory.dirid= ' . $dir_id; $feedPage = 'directory'; } elseif ($extension != 'com_content') { unset($this->Review->joins['listings'], $this->Review->joins['jreviews_categories'], $this->Review->joins['listings']); $feedPage = 'everywhere'; } if ($listing_id > 0) { $queryData['conditions'][] = 'Review.pid = ' . $listing_id; $feedPage = 'listing'; } # Don't run it here because it's run in the Everywhere Observer Component $this->Review->runProcessRatings = false; $reviews = $this->Review->findAll($queryData); $this->set(array('feedPage' => $feedPage, 'encoding' => $this->encoding, 'rss' => $rss, 'reviews' => $reviews)); return $this->Feeds->saveFeed($feed_filename, 'reviews'); }
function startup(&$controller) { if (!isset($controller->Config) || $controller->ajaxRequest || Sanitize::getString($controller->params, 'action') == 'xml') { return; } $this->c =& $controller; $this->cacheCleaner(); $this->rebuildRankTable(); }
function saveInPlace() { $column = Sanitize::getString($this->data, 'column'); $fieldid = Sanitize::getInt($this->data, 'fieldid'); $value = Sanitize::getString($this->data, 'text'); $this->_db->setQuery("\n UPDATE \n #__jreviews_fields \n SET {$column} = " . $this->quote($value) . "\n\t\t WHERE fieldid = {$fieldid}\n\t\t"); if (!$this->_db->query()) { return false; } // Clear cache clearCache('', 'views'); clearCache('', '__data'); return true; }
function index() { global $Itemid; $cat_id = null; $conditions = array(); $joins = array(); $order = array(); $menu_id = ''; // Read module params $dir_id = Sanitize::getString($this->params['module'], 'dir'); $section_id = Sanitize::getString($this->params, 'section'); $cat_id = Sanitize::getString($this->params['module'], 'cat'); $criteria_id = Sanitize::getString($this->params['module'], 'criteria'); $itemid_options = Sanitize::getString($this->params['module'], 'itemid_options'); $itemid_hc = Sanitize::getInt($this->params['module'], 'hc_itemid'); $field = Sanitize::getString($this->params['module'], 'field'); $option_length = Sanitize::getInt($this->params['module'], 'fieldoption_length'); $custom_params = Sanitize::getString($this->params['module'], 'custom_params'); $sort = Sanitize::getString($this->params['module'], 'fieldoption_order'); # Set menu id switch ($itemid_options) { case 'none': $menu_id = ''; break; case 'current': break; case 'hardcode': $menu_id = $itemid_hc; break; } # Category auto detect if (Sanitize::getInt($this->params['module'], 'catauto')) { $ids = CommonController::_discoverIDs($this); extract($ids); } $this->FieldOption->modelUnbind(array('FieldOption.value AS `FieldOption.value`', 'FieldOption.fieldid AS `FieldOption.fieldid`', 'FieldOption.image AS `FieldOption.image`', 'FieldOption.ordering AS `FieldOption.ordering`', 'FieldOption.optionid AS `FieldOption.optionid`', 'FieldOption.text AS `FieldOption.text`')); $fields[] = 'FieldOption.optionid AS `FieldOption.optionid`'; $fields[] = 'FieldOption.value AS `FieldOption.value`'; if ($option_length) { $fields[] = 'IF(CHAR_LENGTH(FieldOption.text)>' . $option_length . ',CONCAT(SUBSTR(FieldOption.text,1,' . $option_length . '),"..."),FieldOption.text) AS `FieldOption.text`'; } else { $fields[] = 'FieldOption.text AS `FieldOption.text`'; } $joins[] = 'INNER JOIN #__jreviews_fields AS Field ON Field.fieldid = FieldOption.fieldid'; $order[] = 'FieldOption.' . $sort; $field_options = $this->FieldOption->findAll(array('fields' => $fields, 'conditions' => 'Field.name = "' . $field . '"', 'joins' => $joins, 'order' => $order)); # Send variables to view template $this->set(array('field' => $field, 'field_options' => $field_options, 'section_ids' => $section_id, 'category_ids' => $cat_id, 'criteria_id' => $criteria_id, 'menu_id' => $menu_id, 'custom_params' => $custom_params)); return $this->render('modules', 'fields'); }
function startup(&$controller) { $this->inAdmin = defined('MVC_FRAMEWORK_ADMIN'); $this->published = Sanitize::getBool($controller->Config, 'twitter_enable'); $this->tweet_new_listing = Sanitize::getBool($controller->Config, 'twitter_listings'); $this->tweet_new_review = Sanitize::getBool($controller->Config, 'twitter_reviews'); $this->tweet_new_discussion = Sanitize::getBool($controller->Config, 'twitter_discussions'); $this->bitly_user = trim(Sanitize::getString($controller->Config, 'bitly_user')); $this->bitly_key = trim(Sanitize::getString($controller->Config, 'bitly_key')); $this->bitly_history = Sanitize::getBool($controller->Config, 'bitly_history'); App::import('Helper', array('routes', 'html'), 'jreviews'); $this->Routes = RegisterClass::getInstance('RoutesHelper'); $this->Html = RegisterClass::getInstance('HtmlHelper'); $this->c =& $controller; }
function _getList() { $this->Access->init($this->Config); if (!$this->_user->id || !$this->Access->isEditor()) { return '[]'; } $q = $this->User->makeSafe(mb_strtolower(Sanitize::getString($this->data, 'value'), 'utf-8')); if (!$q) { return '[]'; } $query = "\r\n SELECT \r\n id AS id, username AS value, name AS name, CONCAT(username,' (',name,')') AS label, email\r\n FROM \r\n #__users\r\n WHERE \r\n name LIKE " . $this->quoteLike($q) . " \r\n OR \r\n username LIKE " . $this->quoteLike($q) . " \r\n LIMIT 15\r\n "; $this->_db->setQuery($query); $users = $this->_db->loadObjectList(); return json_encode($users); }
function index($params) { if ($this->_user->id === 0) { $this->cacheAction = Configure::read('Cache.expires'); } $this->action = 'directory'; // Set view file $page = array('title' => '', 'show_title' => 0); $conditions = array(); $order = array(); $directories = $this->Directory->getTree(Sanitize::getString($this->params, 'dir')); if ($menu_id = Sanitize::getInt($this->params, 'Itemid')) { $menuParams = $this->Menu->getMenuParams($menu_id); $page['title'] = Sanitize::getString($menuParams, 'title'); $page['show_title'] = Sanitize::getString($menuParams, 'dirtitle', 0); } $this->set(array('page' => $page, 'directories' => $directories)); }
function _save() { $this->autoRender = false; $this->autoLayout = false; $response = array(); # Validate form token $this->components = array('security'); $this->__initComponents(); if ($this->invalidToken) { return $this->ajaxError(s2messages::invalidToken()); } if ($this->Config->user_report) { $this->data['Report']['report_text'] = Sanitize::getString($this->data['Report'], 'report_text'); $listing_id = $this->data['Report']['listing_id'] = Sanitize::getInt($this->data['Report'], 'listing_id'); $review_id = $this->data['Report']['review_id'] = Sanitize::getInt($this->data['Report'], 'review_id'); $post_id = $this->data['Report']['post_id'] = Sanitize::getInt($this->data['Report'], 'post_id'); $extension = $this->data['Report']['extension'] = Sanitize::getString($this->data['Report'], 'extension'); if ($this->data['Report']['report_text'] != '') { $this->data['Report']['user_id'] = $this->_user->id; $this->data['Report']['ipaddress'] = $this->ipaddress; $this->data['Report']['created'] = date('Y-m-d H:i:s'); $this->data['Report']['approved'] = 0; if ($this->_user->id) { $this->data['Report']['name'] = $this->_user->name; $this->data['Report']['username'] = $this->_user->username; $this->data['Report']['email'] = $this->_user->email; } else { $this->data['Report']['name'] = 'Guest'; $this->data['Report']['username'] = '******'; } if ($this->Report->store($this->data)) { $update_text = __t("Your report was submitted, thank you.", true); $response[] = "jQuery('#jr_reportLink" . ($post_id > 0 ? $post_id : $review_id) . "').remove();"; return $this->ajaxUpdateDialog($update_text, $response); } return $this->ajaxError(s2Messages::submitErrorDb()); } # Validation failed if (isset($this->Security)) { $reponse[] = "jQuery('jr_reportToken').val('" . $this->Security->reissueToken() . "')"; } return $this->ajaxValidation(__t("The message is empty.", true), $response); } }
function startup(&$controller) { $this->inAdmin = defined('MVC_FRAMEWORK_ADMIN'); $this->published = Sanitize::getBool($controller->Config, 'twitter_enable'); $this->tweet_new_listing = Sanitize::getBool($controller->Config, 'twitter_listings'); $this->tweet_new_review = Sanitize::getBool($controller->Config, 'twitter_reviews'); $this->tweet_new_discussion = Sanitize::getBool($controller->Config, 'twitter_discussions'); $this->bitly_user = trim(Sanitize::getString($controller->Config, 'bitly_user')); $this->bitly_key = trim(Sanitize::getString($controller->Config, 'bitly_key')); $this->bitly_history = Sanitize::getBool($controller->Config, 'bitly_history'); App::import('Helper', array('routes', 'html'), 'jreviews'); $this->Routes = ClassRegistry::getClass('RoutesHelper'); $this->Html = ClassRegistry::getClass('HtmlHelper'); $this->c =& $controller; /** * Tweets configuration * You can customize the strings below for the Twitter messages */ $this->activities = array('listing_new' => __t("Listing: %1\$s. %2\$s", true), 'review_new' => __t("Review for: %1\$s. %2\$s", true), 'comment_new' => __t("Discussion on: %1\$s. %2\$s", true)); }
function reviews() { $extension = Sanitize::getString($this->params, 'extension', 'com_content'); $cat_id = Sanitize::getInt($this->params, 'cat'); $section_id = Sanitize::getInt($this->params, 'section'); $dir_id = Sanitize::getInt($this->params, 'dir'); $listing_id = Sanitize::getInt($this->params, 'id'); $this->encoding = cmsFramework::getCharset(); $feedPage = null; $this->EverywhereAfterFind = true; // Triggers the afterFind in the Observer Model $this->limit = $this->Config->rss_limit; $rss = array('title' => $this->Config->rss_title, 'link' => WWW_ROOT, 'description' => $this->Config->rss_description, 'image_url' => WWW_ROOT . "images/stories/" . $this->Config->rss_image, 'image_link' => WWW_ROOT); $queryData = array('conditions' => array('Review.published = 1', "Review.mode = '{$extension}'"), 'fields' => array('Review.mode AS `Review.extension`'), 'limit' => $this->limit, 'order' => array('Review.created DESC')); if ($cat_id > 0 && $extension == 'com_content') { // Category feeds only supported for core content $queryData['conditions'][] = 'JreviewsCategory.id= ' . $cat_id; // $queryData['joins'] = $this->Listing->joinsReviews; $feedPage = 'category'; } elseif ($section_id > 0 && $extension == 'com_content') { $queryData['conditions'][] = 'Listing.sectionid= ' . $section_id; // $queryData['joins'] = $this->Listing->joinsReviews; $feedPage = 'section'; } elseif ($dir_id > 0 && $extension == 'com_content') { $queryData['conditions'][] = 'JreviewsCategory.dirid= ' . $dir_id; // $queryData['joins'] = $this->Listing->joinsReviews; $feedPage = 'directory'; } elseif ($extension != 'com_content') { unset($this->Review->joins['listings'], $this->Review->joins['jreviews_categories'], $this->Review->joins['listings']); $feedPage = 'everywhere'; } if ($listing_id > 0) { $queryData['conditions'][] = 'Review.pid = ' . $listing_id; $feedPage = 'listing'; } # Don't run it here because it's run in the Everywhere Observer Component $this->Review->runProcessRatings = false; $reviews = $this->Review->findAll($queryData); $this->set(array('feedPage' => $feedPage, 'encoding' => $this->encoding, 'rss' => $rss, 'reviews' => $reviews)); return $this->Feeds->saveFeed(PATH_ROOT . DS . 'cache' . DS . 'jreviewsfeed_' . md5($this->here) . '.xml', 'reviews'); }
function _save() { $this->autoRender = false; $this->autoLayout = false; $this->components = array('security'); $this->__initComponents(); $listing_id = Sanitize::getInt($this->data['Claim'], 'listing_id'); $response = array(); # Validate form token if ($this->invalidToken) { return $this->ajaxError(s2Messages::invalidToken()); } if (!$listing_id) { return $this->ajaxError(s2Messages::accessDenied()); } if ($this->Config->claims_enable && $this->_user->id) { $this->data['Claim']['claim_text'] = Sanitize::getString($this->data['Claim'], 'claim_text'); if ($this->data['Claim']['claim_text'] != '') { // Check if this user already has a claim for this listing to update it $claim_id = $this->Claim->findOne(array('fields' => array('Claim.claim_id AS `Claim.claim_id`'), 'conditions' => array('Claim.user_id = ' . (int) $this->_user->id, 'Claim.listing_id = ' . $listing_id, 'Claim.approved <= 0'))); if ($claim_id > 0) { $this->data['Claim']['claim_id'] = $claim_id; } $this->data['Claim']['user_id'] = $this->_user->id; $this->data['Claim']['created'] = date('Y-m-d H:i:s'); $this->data['Claim']['approved'] = 0; if ($this->Claim->store($this->data)) { $update_text = __t("Your claim was submitted, thank you.", true); $response[] = "jQuery('#jr_claimImg{$listing_id}').remove();"; return $this->ajaxUpdateDialog($update_text, $response); } } else { # Validation failed if (isset($this->Security)) { $response[] = "jQuery('#jr_claimToken').val('" . $this->Security->reissueToken() . "');"; } return $this->ajaxValidation(__t("The message is empty.", true), $response); } } return $this->ajaxError(s2Messages::submitErrorDb()); }
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); } }
function _getList() { $this->Access->init($this->Config); if (!$this->_user || !$this->Access->isEditor()) { return; } $query = $this->User->makeSafe(strtolower(Sanitize::getString($this->params, 'q'))); if (!$query) { return; } $fields = array(' User.id AS `User.user_id`, User.name AS `User.name`, User.username AS `User.username`, User.email AS `User.email` '); $users = $this->User->findAll(array('fields' => $fields, 'conditions' => array("User.username LIKE '%{$query}%' OR User.name LIKE '%{$query}%'"))); foreach ($users as $user) { echo "{$user['User']['name']}|{$user['User']['user_id']}|{$user['User']['username']}|{$user['User']['email']}\n"; } }
function index() { global $Itemid; $cat_id = null; $conditions = array(); $joins = array(); $order = array(); $menu_id = ''; // Read module params $itemid_options = Sanitize::getString($this->params['module'], 'itemid_options'); $itemid_hc = Sanitize::getInt($this->params['module'], 'hc_itemid'); $field = Sanitize::getString($this->params['module'], 'field'); $custom_params = Sanitize::getString($this->params['module'], 'custom_params'); $dir_id = Sanitize::getString($this->params['module'], 'dir'); $section_id = Sanitize::getString($this->params, 'section'); $cat_id = Sanitize::getString($this->params['module'], 'cat'); $criteria_id = Sanitize::getString($this->params['module'], 'criteria'); # Set menu id switch ($itemid_options) { case 'none': $menu_id = ''; break; case 'current': break; case 'hardcode': $menu_id = $itemid_hc; break; } # Category auto detect if (Sanitize::getInt($this->params['module'], 'catauto')) { $ids = CommonController::_discoverIDs($this); extract($ids); } # Send variables to view template $this->set(array('field' => $field, 'dir_id' => $dir_id, 'section_ids' => $section_id, 'category_ids' => $cat_id, 'criteria_id' => $criteria_id, 'menu_id' => $menu_id, 'custom_params' => $custom_params)); return $this->render('modules', 'range'); }
function _send() { $recipient = ''; $error = array(); $response = array(); $this->components = array('security'); $this->__initComponents(); if ($this->invalidToken) { $error[] = 'jQuery("#jr_inquiryTokenValidation").show();'; return json_encode(array('error' => $this->makeJS($error))); } // Required fields $fields = array('name', 'email', 'text'); // $fields = array('name','email','phone','text'); foreach ($fields as $id) { $input_id = '#jr_inquiry' . Inflector::camelize($id) . 'Validation'; if ($this->data['Inquiry'][$id] == '') { $error[] = 'jQuery("' . $input_id . '").show();'; } else { $reponse[] = 'jQuery("' . $input_id . '").hide();'; } } # Validate user's email $this->Listing->validateInput($this->data['Inquiry']['email'], "email", "email", __t("You must fill in a valid email address.", true), 1); # Validate security code if ($this->Access->showCaptcha()) { if (!isset($this->data['Captcha']['code'])) { $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true)); } elseif ($this->data['Captcha']['code'] == '') { $this->Listing->validateSetError("code", __t("You must fill in the security code.", true)); } else { if (!$this->Captcha->checkCode($this->data['Captcha']['code'], $this->ipaddress)) { $this->Listing->validateSetError("code", __t("The security code you entered was invalid.", true)); } } } # Process validation errors $validation = $this->Listing->validateGetErrorArray(); $validation = is_array($validation) ? implode("<br />", $validation) : ''; if (!empty($error) || $validation != '') { // Reissue form token if (isset($this->Security)) { $error[] = "jQuery('#jr_inquiryToken').val('" . $this->Security->reissueToken() . "');"; } if ($this->Access->showCaptcha()) { // Replace captcha with new instance $captcha = $this->Captcha->displayCode(); $error[] = "jQuery('#captcha').attr('src','{$captcha['src']}');"; $error[] = "jQuery('#jr_inquiryCode').val('');"; } if ($validation != '') { $error[] = "jQuery('#jr_inquiryCodeValidation').html('{$validation}').show();"; } return json_encode(array('error' => $this->makeJS($error))); } // Now we can send the email # Read cms mail config settings $configSendmailPath = cmsFramework::getConfig('sendmail'); $configSmtpAuth = cmsFramework::getConfig('smtpauth'); $configSmtpUser = cmsFramework::getConfig('smtpuser'); $configSmtpPass = cmsFramework::getConfig('smtppass'); $configSmtpHost = cmsFramework::getConfig('smtphost'); $configSmtpSecure = cmsFramework::getConfig('smtpsecure'); $configSmtpPort = cmsFramework::getConfig('smtpport'); $configMailFrom = cmsFramework::getConfig('mailfrom'); $configFromName = cmsFramework::getConfig('fromname'); $configMailer = cmsFramework::getConfig('mailer'); # Get the recipient email Configure::write('Cache.query', false); $listing = $this->Listing->findRow(array('fields' => array('User.email AS `Listing.email`'), 'conditions' => array('Listing.id = ' . (int) $this->data['Inquiry']['listing_id']))); $url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true)); $link = '<a href="' . $url . '">' . $listing['Listing']['title'] . '</a>'; switch ($this->Config->inquiry_recipient) { case 'owner': $recipient = Sanitize::getString($listing['Listing'], 'email'); break; case 'admin': $recipient = $configMailFrom; break; case 'field': if (isset($listing['Field']['pairs'][$this->Config->inquiry_field])) { $recipient = $listing['Field']['pairs'][$this->Config->inquiry_field]['value'][0]; } break; } if ($recipient == '') { $recipient = $configMailFrom; } if (!class_exists('PHPMailer')) { App::import('Vendor', 'phpmailer' . DS . 'class.phpmailer'); } $mail = new PHPMailer(); $mail->CharSet = cmsFramework::getCharset(); $mail->SetLanguage('en', S2_VENDORS . 'phpmailer' . DS . 'language' . DS); $mail->Mailer = $configMailer; // Mailer used mail,sendmail,smtp switch ($configMailer) { case 'smtp': $mail->Host = $configSmtpHost; $mail->SMTPAuth = $configSmtpAuth; $mail->Username = $configSmtpUser; $mail->Password = $configSmtpPass; $mail->SMTPSecure = $configSmtpSecure != '' ? $configSmtpSecure : ''; $mail->Port = $configSmtpPort; break; case 'sendmail': $mail->Sendmail = $configSendmailPath; break; default: break; } $mail->isHTML(true); $mail->From = $configMailFrom; $mail->FromName = $configFromName; $mail->addReplyTo($this->data['Inquiry']['email']); $mail->AddAddress($recipient); $mail->Subject = sprintf(__t("New inquiry for: %s", true), $listing['Listing']['title']); $mail->Body = sprintf(__t("From: %s", true), Sanitize::getString($this->data['Inquiry'], 'name')) . "<br />"; $mail->Body .= sprintf(__t("Email: %s", true), Sanitize::getString($this->data['Inquiry'], 'email')) . "<br />"; // $mail->Body .= sprintf(__t("Phone number: %s",true),Sanitize::getString($this->data['Inquiry'],'phone')) . "<br />"; $mail->Body .= sprintf(__t("Listing: %s", true), $listing['Listing']['title']) . "<br />"; $mail->Body .= sprintf(__t("Listing link: %s", true), $link) . "<br />"; $mail->Body .= $this->data['Inquiry']['text']; if (!$mail->Send()) { unset($mail); $error[] = 'jQuery("#jr_inquiryTokenValidation").show();'; return json_encode(array('error' => $this->makeJS($error))); } $mail->ClearAddresses(); $bccAdmin = $this->Config->inquiry_bcc; if ($bccAdmin != '' && $bccAdmin != $recipient) { $mail->AddAddress($bccAdmin); $mail->Send(); } unset($mail); return json_encode(array('error' => $this->makeJS($response), 'html' => true)); }
/** * Calls a controller's method from any location. * * @param string $url URL in the form of Cake URL ("/controller/method/parameter") * @param array $extra if array includes the key "return" it sets the AutoRender to true. * @return mixed Success (true/false) or contents if 'return' is set in $extra * @access public */ function requestAction($url, $extra = array()) { $app = Sanitize::getString($extra, 'app', 'jreviews'); unset($extra['app']); if (empty($url)) { return false; } if (!class_exists('S2Dispatcher')) { require S2_FRAMEWORK . DS . 'dispatcher.php'; } if (in_array('return', $extra, true)) { $extra = array_merge($extra, array('return' => 0, 'autoRender' => 1)); } $params = array_merge(array('token' => cmsFramework::formIntegrityToken($extra, array('module', 'module_id', 'form', 'data'), false), 'autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1), $extra); $disable404 = true; $dispatcher = new S2Dispatcher($app, null, $disable404); return $dispatcher->dispatch($url, $params); }
function _installfix() { // Load fields model App::import('Model', 'field', 'jreviews'); $FieldModel = new FieldModel(); $task = Sanitize::getString($this->data, 'task'); $msg = ''; $mambot_error = 0; switch ($task) { case 'fix_install_jreviews': if (!$this->_installPlugin()) { $msg = "There was a problem updating the database or copying the plugin files. Make sure the Joomla plugins/content folder is writable."; } break; case 'fix_content_fields': $output = ''; $rows = $this->_db->getTableFields(array('#__jreviews_content')); $columns = array_keys($rows['#__jreviews_content']); $sql = "SELECT name,type FROM #__jreviews_fields WHERE location = 'content'"; $this->_db->setQuery($sql); $fields = $this->_db->loadObjectList('name'); $missing = array(); foreach ($fields as $field) { if (!in_array($field->name, $columns)) { $output = $FieldModel->addTableColumn($field->name, $field->type, 'content'); } } $query = "DELETE FROM #__jreviews_fields WHERE name = ''"; $this->_db->setQuery($query); $output = $this->_db->query(); if ($output != '') { $msg = "There was a problem fixing one or more of the content fields"; } break; case 'fix_review_fields': $output = ''; $rows = $this->_db->getTableFields(array('#__jreviews_review_fields')); $columns = array_keys($rows['#__jreviews_review_fields']); $sql = "SELECT name,type FROM #__jreviews_fields WHERE location = 'review'"; $this->_db->setQuery($sql); $fields = $this->_db->loadObjectList('name'); $missing = array(); foreach ($fields as $field) { if (!in_array($field->name, $columns)) { $output = $FieldModel->addTableColumn($field->name, $field->type, 'review'); } } $query = "DELETE FROM #__jreviews_fields WHERE name = ''"; $this->_db->setQuery($query); $output = $this->_db->query(); if ($output != '') { $msg = "There was a problem fixing one or more of the review fields"; } break; default: break; } cmsFramework::redirect("index.php?option=com_jreviews", $msg); }