public function Execute() { if (!CModule::IncludeModule("calendar")) { return CBPActivityExecutionStatus::Closed; } $rootActivity = $this->GetRootActivity(); $documentId = $rootActivity->GetDocumentId(); $documentService = $this->workflow->GetService("DocumentService"); $fromTs = CCalendar::Timestamp($this->CalendarFrom); $toTs = $this->CalendarTo == '' ? $fromTs : CCalendar::Timestamp($this->CalendarTo); $arFields = array("CAL_TYPE" => !$this->CalendarType ? 'user' : $this->CalendarType, "NAME" => trim($this->CalendarName) == '' ? GetMessage('EC_DEFAULT_EVENT_NAME') : $this->CalendarName, "DESCRIPTION" => $this->CalendarDesrc, "SKIP_TIME" => date('H:i', $fromTs) == '00:00' && date('H:i', $toTs) == '00:00', "IS_MEETING" => false, "RRULE" => false); if ($fromTs == $toTs && !$arFields["SKIP_TIME"]) { $toTs += 3600; } $arFields['DATE_FROM'] = CCalendar::Date($fromTs); $arFields['DATE_TO'] = CCalendar::Date($toTs); if ($this->CalendarSection && intVal($this->CalendarSection) > 0) { $arFields['SECTIONS'] = array(intVal($this->CalendarSection)); } if ($this->CalendarOwnerId || $arFields["CAL_TYPE"] != "user" && $arFields["CAL_TYPE"] != "group") { $arFields["OWNER_ID"] = $this->CalendarOwnerId; $eventId = CCalendar::SaveEvent(array('arFields' => $arFields, 'autoDetectSection' => true)); } else { $arCalendarUser = CBPHelper::ExtractUsers($this->CalendarUser, $documentId); foreach ($arCalendarUser as $calendarUser) { $arFields["CAL_TYPE"] = "user"; $arFields["OWNER_ID"] = $calendarUser; $eventId = CCalendar::SaveEvent(array('arFields' => $arFields, 'autoDetectSection' => true)); } } return CBPActivityExecutionStatus::Closed; }
public function index($argv) { $this->stdout("Which environment do you want the application to be initialized in?\n\n"); $i = 1; $envs = []; foreach ($this->config as $name => $value) { $this->stdout($i . '. ' . $name . "\n"); $envs[$i] = $name; $i++; } $in = $this->stdin(); if ($in === 'q') { return; } $in = intVal($in); if ($in >= $i) { $this->error('There is no environment under number ' . $in); return; } if (!$this->confirm("Are you sure you want to initialize the selected environment?")) { return; } $config = $this->config[$envs[$in]]; $this->env_copy($config['path'], path('root')); if (isset($config['rights'])) { $this->set_rights($config['rights']); } }
function getUserItems($feed_ids, $user_id, $start, $start_time, $view_all_items) { $user_id = $this->escape($user_id); //multiple feeds or not if (is_array($feed_ids)) { $ids = implode(',', $this->escapeArray($feed_ids)); } else { $ids = $feed_ids; } if (empty($ids)) { return array(); } $limit = ''; if (!is_null($start)) { $start = intVal($start); $limit = "LIMIT {$start},20"; } $hide_lus = "AND lus.user_id IS NULL "; if ($view_all_items) { $hide_lus = ''; } $query = "SELECT items.id, lus.user_id AS lu, items.item_sid, items.feed_id, items.title, items.content, items.date, items.link, items.author, items.picture, " . "likes.user_id AS s_like " . "FROM items " . "LEFT JOIN lus " . "ON (items.item_sid = lus.item_sid AND lus.user_id = {$user_id} AND lus.time <= {$start_time}) " . "LEFT JOIN likes " . "ON (items.item_sid = likes.item_sid AND likes.user_id = {$user_id}) " . "LEFT JOIN items_filtered AS f " . "ON (items.item_sid = f.item_sid AND f.user_id = {$user_id}) " . "WHERE items.feed_id IN ({$ids}) " . "AND f.user_id IS NULL " . $hide_lus . "AND items.date <= {$start_time} " . "AND (likes.user_id IS NULL OR likes.user_id = {$user_id}) " . "ORDER BY items.date DESC " . $limit; $result = $this->query($query); return $result; }
public function updateAction() { /** * 记录日志 */ $log = "数据用户组修改入库\n\nServerIp:\n" . $this->request->getServer('SERVER_ADDR') . "\n\nGET:\n" . var_export($_GET, true) . "\n\nPOST:\n" . var_export($_POST, true); $this->oLogManager->push('log', $log); //检查权限 $this->manager->checkMenuPermission($this->sign, Widget_Manager::MENU_PURVIEW_UPDATE); $data = $this->request->from('name', 'ClassId'); $group_id = $this->request->group_id; if (!intVal($group_id)) { echo json_encode(array('errno' => 1)); return false; } if (empty($data['name'])) { echo json_encode(array('errno' => 2)); return false; } $oGroup = new Widget_Group(); $res = $oGroup->update($group_id, $data); if (!$res) { echo json_encode(array('errno' => 9)); return false; } echo json_encode(array('errno' => 0)); return true; }
/** * action faq * * @return void */ public function faqAction() { $this->contentObj = $this->configurationManager->getContentObject(); $this->settings['contentID'] = md5($this->contentObj->data['uid']); $template = $this->configuration->template(); if ($template == 1) { $detail = 0; if ($this->request->hasArgument('faq')) { $data = $this->request->getArguments('faq'); if (intVal($data['faq'])) { $detail = $data['faq']; } } $faq = $this->fAQRepository->getFAQData($detail); if ($this->settings['main']['displayFAQ'] == 'CategoryGroupWise' && $detail == 0) { $faq = $this->fAQRepository->getFAQCategoryData($faq, $this->settings['main']['categories']); } if (count($faq) == 0) { $template = array("error" => array('no_records')); } $this->view->assign('FAQ', $faq); $this->view->assign('detail', $detail); } $this->view->assign('template', $template); $this->view->assign('settings', $this->settings); // Include Additional Data $this->configuration->additionalData(); }
public static function CheckFields($ACTION, &$arFields, $ID = 0) { global $DB; if ($ACTION != "ADD" && IntVal($ID) <= 0) { $GLOBALS["APPLICATION"]->ThrowException("System error 870164", "ERROR"); return false; } if ((is_set($arFields, "SITE_ID") || $ACTION == "ADD") && (is_array($arFields["SITE_ID"]) && count($arFields["SITE_ID"]) <= 0 || !is_array($arFields["SITE_ID"]) && strlen($arFields["SITE_ID"]) <= 0)) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GS_EMPTY_SITE_ID"), "EMPTY_SITE_ID"); return false; } elseif (is_set($arFields, "SITE_ID")) { if (!is_array($arFields["SITE_ID"])) { $arFields["SITE_ID"] = array($arFields["SITE_ID"]); } foreach ($arFields["SITE_ID"] as $v) { $dbResult = CSite::GetByID($v); if (!$dbResult->Fetch()) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $v, GetMessage("SONET_GS_ERROR_NO_SITE")), "ERROR_NO_SITE"); return false; } } } if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GS_EMPTY_NAME"), "EMPTY_NAME"); return false; } if (is_set($arFields, "SORT") || $ACTION == "ADD") { $arFields["SORT"] = intVal($arFields["SORT"]) > 0 ? intVal($arFields["SORT"]) : 100; } return True; }
function OnPrepareComments() { $arResult =& $this->component->arResult; $arParams =& $this->component->arParams; $arMessages =& $arResult['MESSAGES']; $arResult['FILES'] = array(); if (!empty($arMessages)) { $res = array_keys($arMessages); $arFilter = array("FORUM_ID" => $arParams["FORUM_ID"], "TOPIC_ID" => $arResult["FORUM_TOPIC_ID"], "APPROVED_AND_MINE" => $GLOBALS["USER"]->GetId(), ">MESSAGE_ID" => intVal(min($res)) - 1, "<MESSAGE_ID" => intVal(max($res)) + 1); if ($arResult["USER"]["RIGHTS"]["MODERATE"] == "Y") { unset($arFilter["APPROVED_AND_MINE"]); } $db_files = CForumFiles::GetList(array("MESSAGE_ID" => "ASC"), $arFilter); if ($db_files && ($res = $db_files->Fetch())) { do { $res["SRC"] = CFile::GetFileSRC($res); if ($arMessages[$res["MESSAGE_ID"]]["~ATTACH_IMG"] == $res["FILE_ID"]) { // attach for custom $arMessages[$res["MESSAGE_ID"]]["~ATTACH_FILE"] = $res; $arMessages[$res["MESSAGE_ID"]]["ATTACH_IMG"] = CFile::ShowFile($res["FILE_ID"], 0, $this->imageSize, $this->imageSize, true, "border=0", false); $arMessages[$res["MESSAGE_ID"]]["ATTACH_FILE"] = $arMessages[$res["MESSAGE_ID"]]["ATTACH_IMG"]; } $arMessages[$res["MESSAGE_ID"]]["FILES"][$res["FILE_ID"]] = $res; $arResult['FILES'][$res["FILE_ID"]] = $res; } while ($res = $db_files->Fetch()); } } }
function __array_stretch($arGroup, $depth = 0) { $arResult = array(); if (intVal($arGroup["ID"]) > 0) { $arResult["GROUP_" . $arGroup["ID"]] = $arGroup; unset($arResult["GROUP_" . $arGroup["ID"]]["GROUPS"]); unset($arResult["GROUP_" . $arGroup["ID"]]["FORUM"]); $arResult["GROUP_" . $arGroup["ID"]]["DEPTH"] = $depth; $arResult["GROUP_" . $arGroup["ID"]]["TYPE"] = "GROUP"; } if (array_key_exists("FORUMS", $arGroup)) { foreach ($arGroup["FORUMS"] as $res) { $arResult["FORUM_" . $res["ID"]] = $res; $arResult["FORUM_" . $res["ID"]]["DEPTH"] = $depth; $arResult["FORUM_" . $res["ID"]]["TYPE"] = "FORUM"; } } if (array_key_exists("GROUPS", $arGroup)) { $depth++; foreach ($arGroup["GROUPS"] as $key => $val) { $res = __array_stretch($arGroup["GROUPS"][$key], $depth); $arResult = array_merge($arResult, $res); } } return $arResult; }
public function getItems() { $items = array(); // get filter ID by attribute code $id = Mage::getResourceModel('amshopby/filter')->getIdByCode($this->getAttributeCode()); if ($id) { $items = Mage::getResourceModel('amshopby/value_collection')->addFieldToFilter('is_featured', 1)->addFieldToFilter('filter_id', $id)->addValue(); if ($this->getRandom()) { $items->setOrder('rand()'); } else { $items->setOrder('featured_order', 'asc'); $items->setOrder('value', 'asc'); $items->setOrder('title', 'asc'); } if ($this->getLimit()) { $items->setPageSize(intVal($this->getLimit())); } /** @var Amasty_Shopby_Helper_Url $hlp */ $hlp = Mage::helper('amshopby/url'); $base = Mage::getBaseUrl('media') . 'amshopby/'; foreach ($items as $item) { if ($item->getImgBig()) { $item->setImgBig($base . $item->getImgBig()); } $query = array($this->getAttributeCode() => $item->getOptionId()); $item->setUrl($hlp->getFullUrl($query, true)); } } return $items; }
public static function ProcessRequest() { if (isset($_REQUEST['component_params_manager'])) { $reqId = intVal($_REQUEST['component_params_manager']); $result = self::GetComponentProperties( $_REQUEST['component_name'], $_REQUEST['component_template'], $_REQUEST['site_template'], $_REQUEST['current_values'] ); $result['description'] = CComponentUtil::GetComponentDescr($_REQUEST['component_name']); ?> <script> window.__bxResult['<?php echo $reqId; ?> '] = <?php echo CUtil::PhpToJSObject($result); ?> ; </script> <? self::DisplayFileDialogsScripts(); } }
public function cacheFilename($format, $arg1 = null, $arg2 = null) { $folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . "/"; $format = $format . $arg1 . $arg2; $format .= $this->addWatermark ? '-wm' . intVal($this->getWatermarkPosition()) . intVal($this->getWatermarkTransparency()) : ''; return $folder . "_resampled/{$format}-" . $this->Name; }
function __MPF_ImageResizeHandler(&$arCustomFile, $arParams = null) { static $arResizeParams = array(); if ($arParams !== null) { if (is_array($arParams) && array_key_exists("width", $arParams) && array_key_exists("height", $arParams)) { $arResizeParams = $arParams; } elseif (intVal($arParams) > 0) { $arResizeParams = array("width" => intVal($arParams), "height" => intVal($arParams)); } } if (!is_array($arCustomFile) || !isset($arCustomFile['fileID'])) { return false; } $fileID = $arCustomFile['fileID']; $arFile = CFile::MakeFileArray($fileID); if (CFile::CheckImageFile($arFile) === null) { $aImgThumb = CFile::ResizeImageGet($fileID, array("width" => 90, "height" => 90), BX_RESIZE_IMAGE_EXACT, true); $arCustomFile['img_thumb_src'] = $aImgThumb['src']; if (!empty($arResizeParams)) { $aImgSource = CFile::ResizeImageGet($fileID, array("width" => $arResizeParams["width"], "height" => $arResizeParams["height"]), BX_RESIZE_IMAGE_PROPORTIONAL, true); $arCustomFile['img_source_src'] = $aImgSource['src']; $arCustomFile['img_source_width'] = $aImgSource['width']; $arCustomFile['img_source_height'] = $aImgSource['height']; } } }
function indexAction() { $this->setLayout('shares'); $id = intVal($this->getParam('id')); $this->load->model('item'); $item = $this->item->get(array('id' => $id), true); if (!$item) { $this->forward404($id); } $this->frontend->addExtGroup('toolbar', $this->isIE()); $user_id = 0; $ip = $_SERVER['REMOTE_ADDR']; if ($this->auth->isLogged()) { $this->setLayoutVar('logged_in', true); $user = $this->auth->getUser(); $user_id = $user->id; $this->load->model('viewed_post'); $newView = $this->viewed_post->addViewedPost($item->item_sid, $user_id, $ip); if ($newView) { $this->item->increaseItemViewed($id); } header('Location: ' . $item->link); } else { $this->setLayoutVar('logged_in', false); } $URLManager = new URLManager(); $og_metas = $URLManager->grabOGMeta($item->link); $this->setLayoutVar('og_metas', $og_metas); $this->setLayoutVar('item', $item); }
public static function Add($arFields) { global $DB; if (!CForumUserPoints::CheckFields("ADD", $arFields)) { return false; } $arInsert = $DB->PrepareInsert("b_forum_user_points", $arFields); $strDatePostField = ""; $strDatePostValue = ""; if (!is_set($arFields, "DATE_UPDATE")) { $strDatePostField .= ", DATE_UPDATE"; $strDatePostValue .= ", " . $DB->GetNowFunction() . ""; } $strSql = "INSERT INTO b_forum_user_points(" . $arInsert[0] . $strDatePostField . ") VALUES(" . $arInsert[1] . $strDatePostValue . ")"; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); // Recount user points if (intVal($arFields["TO_USER_ID"]) > 0) { $arUserFields = array("POINTS" => CForumUser::CountUserPoints($arFields["TO_USER_ID"])); $arUser = CForumUser::GetByUSER_ID($arFields["TO_USER_ID"]); if ($arUser) { CForumUser::Update(intVal($arUser["ID"]), $arUserFields); } else { $arUserFields["USER_ID"] = $arFields["TO_USER_ID"]; $ID_tmp = CForumUser::Add($arUserFields); } } return true; }
function __main_post_form_image_resize(&$arCustomFile, $arParams = null) { static $arResizeParams = array(); if ($arParams !== null) { if (is_array($arParams) && array_key_exists("width", $arParams) && array_key_exists("height", $arParams)) { $arResizeParams = $arParams; } elseif (intVal($arParams) > 0) { $arResizeParams = array("width" => intVal($arParams), "height" => intVal($arParams)); } } if (!is_array($arCustomFile) || !isset($arCustomFile['fileID'])) { return false; } if (array_key_exists("ID", $arCustomFile)) { $arFile = $arCustomFile; $fileID = $arCustomFile['ID']; } else { $fileID = $arCustomFile['fileID']; $arFile = CFile::MakeFileArray($fileID); $arFile1 = CFile::GetByID($fileID)->fetch(); if (is_array($arFile) && is_array($arFile1)) { $arCustomFile = array_merge($arFile, $arFile1, $arCustomFile); } } if (CFile::CheckImageFile($arFile) === null) { $aImgThumb = CFile::ResizeImageGet($fileID, array("width" => 90, "height" => 90), BX_RESIZE_IMAGE_EXACT, true); $arCustomFile['img_thumb_src'] = $aImgThumb['src']; if (!empty($arResizeParams)) { $aImgSource = CFile::ResizeImageGet($fileID, array("width" => $arResizeParams["width"], "height" => $arResizeParams["height"]), BX_RESIZE_IMAGE_PROPORTIONAL, true); $arCustomFile['img_source_src'] = $aImgSource['src']; $arCustomFile['img_source_width'] = $aImgSource['width']; $arCustomFile['img_source_height'] = $aImgSource['height']; } } }
function parseFeedsAction() { $service = $this->getParam('service'); $job_name = "_PARSE_FEEDS_SERVICE_{$service}_"; $chunk_size = 20; $offset = $this->getParam('offset'); if (!is_null($offset)) { $offset = intVal($offset); } else { $offset = -1; } $started = $this->jobs->run($job_name); if ($offset === -1 && !$started) { //exit; $this->triggerErrorEmail('parsing feeds could not be started, service ' . $service); } if ($offset === -1) { exec('php index.php job parseFeeds offset 0 service ' . $service . ' > /dev/null &' . "\n"); exit; } $this->load->model('feed'); $ids = $this->feed->getIdsForParsingWithOffset($chunk_size); if (!empty($ids)) { //$ids_string = implode(',',$ids); $this->load->model('services/feeds'); //not checking time as it was already checked $this->feeds->parseFeed($ids, false); } if (count($ids) == $chunk_size) { exec('php index.php job parseFeeds offset 0 service ' . $service . ' > /dev/null &'); } else { $this->jobs->end($job_name); } exit; }
public static function ConvertFromDB($arProperty, $value) { if (strlen($value["VALUE"]) > 0) { $value["VALUE"] = intVal($value["VALUE"]); } return $value; }
/** * For WSSE Header generation, use http://www.teria.com/~koseki/tools/wssegen/ . * Simple, efficient. (auto nonce, auto date. No before wsse. User = username in database, password = encypted salt+password = password as in database) * * Install and open Rest Console for chrome. Fields to use : * Request API : Your server address, with an API service (http://obtao.localhost/app_dev.php/api/me for us) * Custom Header (+) : * - Parameter = “x-wsse“, * - Value * Host: localhost * X-WSSE: UsernameToken Username="******", PasswordDigest="GtGn8TZX/KVlEQuerkESVElc64g=", Nonce="NzViZGU3NjM5MTAzZmU1Nw==", Created="2015-02-18T17:09:12Z" * Authorization: Basic YWRtaW46YWRtaW4= * Authorization Hearder : Authorization profile=”UsernameToken” * * @link http://www.teria.com/~koseki/tools/wssegen/ * @Route("/user/authentication", name="wsse_users_authentication") * @Method("GET") */ public function authenticationAction(Request $request) { $response = new Response(); $response->headers->set('Content-Type', 'application/json'); $user = $this->container->get('security.context')->getToken()->getUser(); $locale = $this->container->get("request")->getLocale(); if ($user instanceof User) { $response->setContent($this->getUserInformation($user)); $response->setStatusCode(200); // Record all cookies in relation with ws. $dateExpire = $this->container->getParameter('sfynx.core.cookies.date_expire'); $date_interval = $this->container->getParameter('sfynx.core.cookies.date_interval'); // Record the layout variable in cookies. if ($dateExpire && !empty($date_interval)) { if (is_numeric($date_interval)) { $dateExpire = time() + intVal($date_interval); } else { $dateExpire = new \DateTime("NOW"); $dateExpire->add(new \DateInterval($date_interval)); } } else { $dateExpire = 0; } // we apply all events allowed to change the redirection response $event_response = new ResponseEvent(null, $dateExpire, $this->getRequest(), $user, $locale); $this->container->get('event_dispatcher')->dispatch(SfynxAuthEvents::HANDLER_LOGIN_CHANGERESPONSE, $event_response); // foreach ($event_response->getResponse()->headers->getCookies() as $cokkie) { $response->headers->setCookie($cokkie); } } return $response; }
public static function getSetup() { global $wgUser, $IP, $wgMemc; $isHHM = wikihowAds::isHHM(); $isABTest = wikihowAds::isABTestArticle(); $cachekey = wfMemcKey('ads_setup', intval($isHHM), intval($isABTest), WH_SITEREV); //$html = $wgMemc->get($cachekey); $html = null; if ($html === null) { $js = wfMsg('Wikihowads_setup', $isHHM, intVal($isABTest)); require_once "{$IP}/extensions/min/lib/JSMinPlus.php"; $adsClass = file_get_contents("{$IP}/extensions/wikihow/wikihowAds/wikihowAds.js"); $min = JSMinPlus::minify($adsClass . $js); $html = <<<EOHTML <!-- MediaWiki:wikihowads_setup --> <script type='text/javascript'> <!-- {$min} //--> </script> EOHTML; $wgMemc->set($cachekey, $html); } return $html; }
public function apply(Zend_Controller_Request_Abstract $request, $filterBlock) { $filter = Mage::helper('adjnav')->getParam($this->_requestVar); $filter = explode('-', $filter); $ids = array(); foreach ($filter as $id) { $id = intVal($id); if ($id) { $ids[] = $id; } } if ($ids) { $this->applyMultipleValuesFilter($ids); } //compatibility with SOLR if (Mage::helper('adjnav')->isSolrEnabled()) { $this->applySolrFilter($ids); } //compatibility with SOLR // Increment attribute usage statistics data if (count($ids)) { Mage::getModel('adjnav/eav_entity_attribute_option_stat')->addStat($ids); } $this->setActiveState($ids); return $this; }
function getOrderWithAccountAndDeadline($accountEmail, $deadline) { global $GetOrder_URL; $orders = array(); $json = file_get_contents($GetOrder_URL); $data = json_decode($json, TRUE); $rows = $data['feed']['entry']; foreach ($rows as $item) { $account_email = $item['gsx$account']['$t']; $orderDeadline = $item['gsx$orderdeadline']['$t']; if ($orderDeadline === $deadline && (strlen($accountEmail) === 0 || $accountEmail == $account_email)) { $timeStamp = $item['gsx$timestamp']['$t']; $pickup = $item['gsx$pickup']['$t']; $vendor = $item['gsx$vendor']['$t']; $price = $item['gsx$price']['$t']; $remit = $item['gsx$remit']['$t']; $count = $item['gsx$count']['$t']; $remitRate = trim($remit); $remitRateFloat = floatVal($remitRate) / 100.0; //trim off % sign; $countInt = intVal($count); $price = trim($price); $price = substr($price, 1, strlen($price) - 1); $priceFloat = floatVal($price); array_push($orders, array($timeStamp, $account_email, $pickup, $vendor, $priceFloat, $remitRateFloat, $countInt)); } } return $orders; }
/** * Tests if this is a return to the initialization page of the pref wizard * * @return boolean true if it is a return to init page, false otherwise */ function isReturnToInit() { if (isset($_POST['previous']) && intVal($_POST['pref_index']) == 0) { return true; } return false; }
function getArrayOfSearch($search) { $pass1 = explode('"', $search); //separating guillemet $pass2 = array(); $index = 1; foreach ($pass1 as $p) { $mod = $index / 2; if (intVal($mod) == $mod) { $result = $p; if ($result != '') { $pass2[] = $result; } } else { $p2 = explode(' ', $p); foreach ($p2 as $pp2) { $result = str_replace(' ', '', $pp2); if ($result != '') { $pass2[] = $result; } } } $index++; } return $pass2; }
public function getItems() { $items = array(); // get filter ID by attribute code $id = Mage::getResourceModel('amshopby/filter')->getIdByCode($this->getAttributeCode()); if ($id) { $items = Mage::getResourceModel('amshopby/value_collection')->addFieldToFilter('is_featured', 1)->addFieldToFilter('filter_id', $id)->addValue(); if ($this->getRandom()) { $items->setOrder('rand()'); } else { $items->setOrder('value', 'asc'); $items->setOrder('title', 'asc'); } if ($this->getLimit()) { $items->setPageSize(intVal($this->getLimit())); } $hlp = Mage::helper('amshopby/url'); $base = Mage::getBaseUrl('media') . 'amshopby/'; foreach ($items as $item) { $item->setImgBig($base . $item->getImgBig()); $attrCode = $this->getAttributeCode(); $optLabel = $item->getValue() ? $item->getValue() : $item->getTitle(); $optId = $item->getOptionId(); $item->setUrl($hlp->getOptionUrl($attrCode, $optLabel, $optId)); } } return $items; }
/** * Adds the command label to the mass actions list * * @param Amasty_Paction_Block_Adminhtml_Catalog_Product_Grid $grid * @return Amasty_Paction_Model_Command_Abstract */ public function addAction($block) { $hlp = Mage::helper('ampaction'); $storeId = intVal(Mage::app()->getRequest()->getParam('store')); $block->addItem('ampaction_' . $this->_type, array('label' => $hlp->__($this->_label), 'url' => $block->getParentBlock()->getUrl('ampaction/adminhtml_index/do/command/' . $this->_type . '/store/' . $storeId), 'additional' => $this->_getValueField($hlp->__($this->_fieldLabel)))); return $this; }
protected function checkInt($val) { if (preg_match('/^-?\\d+$/', $val)) { return intVal($val); } return null; }
/** * Decode an HTTP Response. * @static * @throws Analytify_Google_Service_Exception * @param Analytify_Google_Http_Request $response The http response to be decoded. * @return mixed|null */ public static function decodeHttpResponse($response) { $code = $response->getResponseHttpCode(); $body = $response->getResponseBody(); $decoded = null; if (intVal($code) >= 300) { $decoded = json_decode($body, true); $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl(); if (isset($decoded['error']) && isset($decoded['error']['message']) && isset($decoded['error']['code'])) { // if we're getting a json encoded error definition, use that instead of the raw response // body for improved readability $err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}"; } else { $err .= ": ({$code}) {$body}"; } $errors = null; // Specific check for APIs which don't return error details, such as Blogger. if (isset($decoded['error']) && isset($decoded['error']['errors'])) { $errors = $decoded['error']['errors']; } throw new Analytify_Google_Service_Exception($err, $code, null, $errors); } // Only attempt to decode the response, if the response code wasn't (204) 'no content' if ($code != '204') { $decoded = json_decode($body, true); if ($decoded === null || $decoded === "") { throw new Analytify_Google_Service_Exception("Invalid json in service response: {$body}"); } if ($response->getExpectedClass()) { $class = $response->getExpectedClass(); $decoded = new $class($decoded); } } return $decoded; }
function joinGameChallenge($d) { $fromID = intVal($d["fromID"], 10); $challengeId = intVal($d["challengeId"], 10); $res = array(); global $mysqli; //getting the chats for todays date $sql = "Select gameID from game where challengeId=? and playerID0=?;"; try { if ($stmt = $mysqli->prepare($sql)) { $stmt->bind_param("ii", $challengeId, $fromID); $data = returnJson($stmt); $stmt->close(); $mysqli->close(); if (!$data || empty($data)) { $res["success"] = false; $res["message"] = "No challenges accepted."; } else { $res["success"] = true; $res["response"] = $data; } return json_encode($res); } } catch (mysqli_sql_exception $e) { throw new MySQLiQueryException($SQL, $e->getMessage(), $e->getCode()); } catch (Exception $e) { echo log_error($e, $sql, null); //return false; echo 'fail'; } }
/** * Decode an HTTP Response. * @static * @throws Google_ServiceException * @param Google_HttpRequest $response The http response to be decoded. * @return mixed|null */ public static function decodeHttpResponse($response) { $code = $response->getResponseHttpCode(); $body = $response->getResponseBody(); $decoded = null; if (intVal($code) >= 300) { $decoded = json_decode($body, true); $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl(); if ($decoded != null && isset($decoded['error']['message']) && isset($decoded['error']['code'])) { // if we're getting a json encoded error definition, use that instead of the raw response // body for improved readability $err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}"; } else { $err .= ": ({$code}) {$body}"; } throw new Google_ServiceException($err, $code, null, $decoded['error']['errors']); } // Only attempt to decode the response, if the response code wasn't (204) 'no content' if ($code != '204') { $decoded = json_decode($body, true); if ($decoded === null || $decoded === "") { throw new Google_ServiceException("Invalid json in service response: {$body}"); } } return $decoded; }
public function getTagListRows($rawTag, $offset, $rows = NUM_ROWS, $filter = null) { global $wgUser; $db = WAPDB::getInstance($this->dbType); $orderBy = 'ct_rank'; $filter = intVal($filter); // Don't pass in a filter, will filter below $vars['articles'] = $db->getArticlesByTagName($rawTag, 0, self::MAX_NUM_ROWS, WAPArticleTagDB::ARTICLE_UNASSIGNED, '', $orderBy); if (!empty($filter)) { foreach ($vars['articles'] as $i => $a) { // bitwise filter by category if (!($a->getCatInfo() & $filter)) { unset($vars['articles'][$i]); } } } $vars['u'] = BabelfishUser::newFromUserObject($wgUser, $this->dbType); $vars['numrows'] = $rows; $vars['tag'] = $rawTag; $config = WAPDB::getInstance($this->dbType)->getWAPConfig(); $linkerClass = $config->getLinkerClassName(); $vars['linker'] = new $linkerClass($this->dbType); $tmpl = new WAPTemplate($this->dbType); $html = $tmpl->getHtml('tag_list_pager_rows.tmpl.php', $vars); return $html; }