/** * Vaidate the file MIME type. * * @param string $file * @return bool */ public function isValid($file) { $this->_file = $file; // Detect the definitive MIME type. $detect = new Omeka_File_MimeType_Detect($this->_file); $this->_mimeType = $detect->detect(); // Set the relevant MIME type whitelist. if ($this->_customWhitelist) { $whitelist = $this->_customWhitelist; } else { $whitelist = self::DEFAULT_WHITELIST; } // Validate the MIME type against the whitelist. if (in_array($this->_mimeType, explode(',', $whitelist))) { // Valid MIME type. Set the MIME type to the ingest class so that it // can assign it to the File record. Doing this avoids more than one // call to the MIME type detection class. Omeka_File_Ingest_AbstractIngest::$mimeType = $this->_mimeType; return true; } else { // Invalid MIME type. Zend_Debug::dump(explode(',', $whitelist)); $this->_error(self::INVALID_TYPE); return false; } }
public function postProcess(Axis_Sales_Model_Order_Row $order) { $this->saveCreditCard($order); $cc = $this->getCreditCard(); $options = $this->getLineItemDetails(); $billing = $order->getBilling(); $optionsAll = array_merge($options, array('STREET' => $billing->getStreetAddress(), 'ZIP' => $billing->getPostcode(), 'BUTTONSOURCE' => $this->_buttonSourceDP, 'CURRENCY' => $this->getBaseCurrencyCode(), 'IPADDRESS' => $_SERVER['REMOTE_ADDR'])); if ($cc->getCcIssueMonth() && $cc->getCcIssueYear()) { $optionsAll['CARDSTART'] = $cc->getCcIssueMonth() . substr($cc->getCcIssueYear(), -2); } $optionsNVP = array('CITY' => $billing->getCity(), 'STATE' => $billing->getZone()->getCode() ? $billing->getZone()->getCode() : $billing->getCity(), 'COUNTRYCODE' => $billing->getCountry()->getIsoCode2(), 'EXPDATE' => $cc->getCcExpiresMonth() . $cc->getCcExpiresYear(), 'PAYMENTACTION' => $this->_config->paymentAction == 'Authorization' ? 'Authorization' : 'Sale'); $delivery = $order->getDelivery(); $optionsShip = array('SHIPTONAME' => $delivery->getFirstname() . ' ' . $delivery->getLastname(), 'SHIPTOSTREET' => $delivery->getStreetAddress(), 'SHIPTOSTREET2' => $delivery->getSuburb(), 'SHIPTOCITY' => $delivery->getCity(), 'SHIPTOZIP' => $delivery->getPostcode(), 'SHIPTOSTATE' => $delivery->getZone()->getCode() ? $delivery->getZone()->getCode() : $delivery->getCity(), 'SHIPTOCOUNTRYCODE' => $delivery->getCountry()->getIsoCode2()); // if these optional parameters are blank, remove them from transaction if (isset($optionsShip['SHIPTOSTREET2']) && empty($optionsShip['SHIPTOSTREET2'])) { unset($optionsShip['SHIPTOSTREET2']); } $response = $this->getApi()->DoDirectPayment(sprintf('%.2f', $this->getAmountInBaseCurrency($order->order_total)), $cc->getCcNumber(), $cc->getCcCvv(), $cc->getCcExpiresMonth() . $cc->getCcExpiresYear(), $billing->getFirstname(), $billing->getLastname(), $cc->getCcType(), $optionsAll, array_merge($optionsNVP, $optionsShip)); if ($response['ACK'] != 'Success') { $this->log("Response : " . Zend_Debug::dump($response, null, false)); foreach ($this->getMessages($response) as $severity => $messages) { Axis::message()->batchAdd($messages, $severity); } throw new Axis_Exception('DoDirectPayment Failure'); } }
protected function _afterSave() { $payment = $this->getPayment(); if ($payment->getStatus() == 3) { if ($payment->getPaymentMethod() == 'bank') { $verify = Mage::getModel('affiliateplus/payment_verify')->loadExist($payment->getAccountId(), $this->getBankaccountId(), 'bank'); if (!$verify->isVerified()) { try { $verify->setVerified(1)->save(); } catch (Exception $e) { } } } } elseif ($payment->getStatus() == 1) { if ($payment->getPaymentMethod() == 'bank') { $verify = Mage::getModel('affiliateplus/payment_verify')->loadExist($payment->getAccountId(), 0, 'bank'); if ($verify->getId()) { try { $verify->setData('field', $this->getBankaccountId())->save(); } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); } } } } }
protected function debug() { $vars = func_get_args(); foreach ($vars as $var) { Zend_Debug::dump($var); } }
public function smsLinkAction() { $ObtenerNumero = new Core_Utils_Utils(); $telefono = $ObtenerNumero->obtenerNumero(); if ($this->_request->isGet()) { $codigo = $this->_getParam('i', ''); try { if (isset($codigo) && $codigo != '' && $telefono != '') { $resultSms = $this->_GetResultSoap->_obtenerSMSLinkEnFulltracks($codigo); Zend_Debug::dump($resultSms); $responseSmnLinkFt = $resultSms->obtenerSMSLinkEnFulltracksResult; if ($responseSmnLinkFt->esValido == true && $responseSmnLinkFt->numuser == $telefono) { $this->_redirect('/pe/fulltracks'); } else { $this->_redirect('http://m.entretenimiento.entel.pe'); } } else { $this->_redirect('http://m.entretenimiento.entel.pe'); } } catch (Exception $e) { $this->_redirect('http://m.entretenimiento.entel.pe'); } } else { $this->_redirect('http://m.entretenimiento.entel.pe'); } }
public function authenticate() { $consumer = new Zend_Oauth2_Consumer($this->_config); try { if (isset($_GET['code']) && !empty($_GET['code'])) { $options = array('client_id' => $this->_config['consumerId'], 'redirect_uri' => $this->_config['callbackUrl'], 'client_secret' => $this->_config['consumerSecret'], 'code' => trim($_GET['code']), 'grant_type' => 'authorization_code'); $accessTokenInfo = $consumer->getAccessToken($options); Zend_Debug::dump($accessTokenInfo); $accessToken = $accessTokenInfo['access_token']; $options = array('app_id' => $this->_config['consumerId'], 'method' => 'users.getInfo', 'secure' => 1, 'session_key' => $accessToken); $sign = $this->getSign($options, $accessToken); $options['sig'] = $sign; $identity = $consumer->getIdentity($options, 'POST'); $identity = reset($identity); $identity['CONSUMER_ID'] = $this->_consumerId; return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, (object) $identity); } elseif (!isset($_GET['error'])) { $consumer->redirect(array('client_id' => $this->_config['consumerId'], 'redirect_uri' => $this->_config['callbackUrl'], 'response_type' => 'code')); } else { throw new Exception($_GET['error']); } } catch (Exception $e) { return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, false, array($e->getMessage())); } }
public function getblockAction() { $param = Mage::app()->getFrontController()->getRequest()->getParams(); if ($param["create"] !== "false") { $this->loadLayout(); if ($item_block = $this->getLayout()->getBlock($param["name"])) { if ($param["template"]) { $item_block->setTemplate($param["template"]); } } } else { $item_layout = Mage::getSingleton('core/layout'); if ($item_block = $item_layout->createBlock($param["class_name"], $param["name"])) { if ($param["template"]) { $item_block->setTemplate($param["template"]); } } else { echo "not exist this class " . $param["class_name"]; die; } } if ($param["onlychild"] == "true") { Zend_Debug::dump($item_block->getChild()); } else { echo $item_block->renderView(); } exit; }
public function errorAction() { $errors = $this->_getParam('error_handler'); Zend_Debug::dump($errors); exit; switch ($errors->type) { case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: // 404 error -- controller or action not found $this->getResponse()->setHttpResponseCode(404); $this->view->message = 'Page not found'; break; default: // application error $this->getResponse()->setHttpResponseCode(500); $this->view->message = 'Application error'; break; } // Log exception, if logger available if ($log = $this->getLog()) { $log->crit($this->view->message, $errors->exception); } // conditionally display exceptions if ($this->getInvokeArg('displayExceptions') == true) { $this->view->exception = $errors->exception; } $this->view->request = $errors->request; //$this->view->layout()->disableLayout(); }
private function _updateUserDb() { $fb_users = HTS_Util::getDbTable('users'); $fb_user = $fb_users->findOneByIdSocial($this->_id_social); if (empty($fb_user)) { $user_profile = $this->_social->api('/me'); if (FB_DEBUG) { Zend_Debug::dump($user_profile); } $fb_user = HTS_Util::getDbRow('users'); $birthday = new Zend_Date(@$user_profile['Birthday'], 'dd/MM/yyyy'); $updated_time = new Zend_Date(@$user_profile['Updated_time']); //TODO some values are null -> undefined index warning $fb_user->id_social = $user_profile['Id']; $fb_user->name = $user_profile['Name']; $fb_user->first_name = @$user_profile['First_name']; $fb_user->middle_name = @$user_profile['Middle_name']; $fb_user->last_name = @$user_profile['Last_name']; $fb_user->link = $user_profile['Link']; $fb_user->birthday = @$birthday->toString('yyyy/MM/dd'); $fb_user->gender = $user_profile['Gender']; $fb_user->timezone = @$user_profile['Timezone']; $fb_user->locale = @$user_profile['Locale']; $fb_user->time_created = time(); $fb_user->time_modified = time(); $fb_user->time_social_modified = $updated_time->toValue(); $this->_id_user = $fb_user->save(); } $this->_user = $fb_user; $this->_id_user = $fb_user->id; }
public function getSingle($text) { $args = array('appid' => $this->_appid, 'documentContent' => urlencode($text . ' ' . $this->_suffix), 'documentType' => 'text/plain', 'outputType' => 'xml'); $response = $this->curl($text, $args); // Now parse the response using PHP SimpleXML $xml = simplexml_load_string($response); Zend_Debug::dump($xml); $place = new Place(); if (isset($xml->results->place->name)) { $place->name = $xml->results->place->name; } if (isset($xml->results->place->centroid->longitude)) { $place->longitude = $xml->results->place->centroid->longitude; } if (isset($xml->results->place->centroid->latitude)) { $place->latitude = $xml->results->place->centroid->latitude; } if (isset($xml->results->place->woeid)) { $place->woeid = $xml->results->place->woeid; } if (isset($xml->results->place->placeTypeName)) { $place->type = $xml->results->place->placeTypeName; } if (isset($xml->results->place->postal)) { $place->postal = $xml->results->place->postal; } return $place; }
public static function copyFrom(Twig_Node_Expression_GetAttr $node) { Zend_Debug::dump($node->__toString()); $node = new Zwig_Node_Expression_GetAttr($node->node, $node->attribute, $node->arguments, $node['type'], $node->lineno); Zend_Debug::dump($node->__toString()); return $node; }
public function loginAction() { //$this->_helper->layout()->disableLayout(); $formAuthLogin = new Form_Auth_Login(); $this->view->form = $formAuthLogin; if ($this->getRequest()->isPost()) { if ($formAuthLogin->isValid($this->getRequest()->getPost())) { $dadosAutenticacao = $formAuthLogin->getValues(); $db = Zend_Registry::get('db'); $authAdapter = new Zend_Auth_Adapter_DbTable($db); try { $authAdapter->setTableName('administrador')->setIdentityColumn('administrador_email')->setCredentialColumn('administrador_senha')->setIdentity($dadosAutenticacao['administrador_email'])->setCredential(md5($dadosAutenticacao['administrador_senha'])); $authAdapter->getDbSelect()->where("administrador_ativo = ?", 1); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); if ($result->isValid()) { $dadosAdministrador = array(); Zend_Auth::getInstance()->getStorage()->write($dadosAdministrador); $this->_redirect("index/"); } else { $this->_helper->flashMessenger->addMessage(array('class' => 'alert alert-danger', 'message' => 'Usuário e/ou senha inválidos!')); Zend_Debug::dump($result); die; $this->_redirect("admin/autenticacao/login"); } } catch (Exception $e) { $this->_helper->flashMessenger->addMessage(array('class' => 'alert alert-danger', 'message' => 'Houve um erro na autenticação - ' . $e->getMessage())); $this->_redirect("auth/login"); } } } }
public function process(Zend_Controller_Request_Abstract $request) { $this->customSetParam = $request->getParam('attributeSet'); //Zend_Debug::dump($this->customSetParam); //Zend_Debug::dump($_FILES['customAttributeDetailImage']); foreach ($this->customSetParam as $k => $v) { $this->customSetName[] = $k; } Zend_Debug::dump($this->customSetName[0]); foreach ($this->customSetParam[$this->customSetName[0]]['name'] as $k => $v) { $this->customSetKey[] = $k; } Zend_Debug::dump($this->customSetKey); $this->customSet->name_of_set = $this->customSetName[0]; $this->customSet->uploader_id = $this->userID; //echo $this->table; //echo $this->userID; //echo $this->customSetName[0]; if (!DatabaseObject_Helper_ManageAttribute::confirmattributenamewithuploader($this->db, $this->table, $this->userID, $this->customSetName[0])) { $this->customSet->save(); $this->attributeID = $this->customSet->getId(); //echo 'here at no error'; return true; } else { //echo 'here at errors'; echo 'duplicate, there is an error'; $this->addError('duplicate', 'this is a duplicate'); return !$this->hasError(); } //return true if no errors have occurred }
public function hasReceivedThisMessage($device_id, $message_id) { $select = $this->_db->select()->from(array('pm' => 'push_messages'), array())->join(array('pdm' => 'push_delivered_message'), 'pdm.app_id = pm.app_id', array('pm.message_id'))->where('pm.message_id = ?', $message_id)->where('pdm.device_type = ?', Push_Model_Iphone_Device::DEVICE_TYPE); Zend_Debug::dump($this->_db->fetchOne($select)); die; return $this->_db->fetchOne($select); }
function upsertAddress($data) { $websiteId = Mage::app()->getWebsite()->getId(); $store = Mage::app()->getStore(); $customer = Mage::getModel("customer/customer"); $customer->setWebsiteId($websiteId); $customer->setStore($store); $customer->loadByEmail($data['email']); if ($customer->getId()) { $address = Mage::getModel("customer/address"); $address->setCustomerId($customer->getId())->setFirstname($data['first_name'])->setLastname($data['last_name'])->setCompant($data['company'])->setTelephone($data['phone'])->setStreetFull(array($data['street_1'], $data['street_2']))->setCity($data['city'])->setCountryId($data['country'])->setPostcode($data['zip_code']); $region = Mage::getModel('directory/region')->loadByCode($data['state_iso2'], $data['country']); $state_id = $region->getId(); if ($region->getId()) { $address->setRegionId($state_id); } else { if ($data['state'] !== '') { $address->setRegion($data['state']); } } $address->setIsDefaultBilling('1')->setIsDefaultShipping('1')->setSaveInAddressBook('1'); try { $address->save(); } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); } } }
public function submitAction() { $this->logger->info('type_projet : submitAction()'); $table_reponse = array('message' => ''); $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $data_from_user = $this->_getAllParams(); if (!empty($data_from_user['nom_type_projet'])) { $data_to_save = array('nom_type_projet' => $data_from_user['nom_type_projet']); $this->logger->info(html_entity_decode(Zend_Debug::dump($data_to_save, $label = null, $echo = false), ENT_COMPAT, "utf-8")); try { $this->db->insert('type_projet', $data_to_save); $this->logger->info('update query : ' . $this->db->getProfiler()->getLastQueryProfile()->getQuery()); $this->logger->info('type de projet ajouter : OUI'); $table_reponse['message'] = 'Le type de projet a été bien ajouter '; } catch (Zend_Db_Adapter_Exception $e) { echo $e->getMessage(); } } else { $table_reponse['message'] = 'erreur'; } $this->db->getProfiler()->setEnabled(false); $json = Zend_Json::encode($table_reponse); echo $json; }
/** * Generates the output text * * @param mixed $var The variable to dump. * @param string $label OPTIONAL Label to prepend to output. * @return string */ protected function _getOutput($var, $label = null) { // format the label // if it is a object, format with its properties $trace = debug_backtrace(); $l = 'FILE: ' . basename($trace[0]['file']) . '<br/>'; $l .= 'FUNCTION: ' . $trace[0]['function'] . '<br/>'; $l .= 'LINE: ' . $trace[0]['line'] . '<br/>'; $l .= 'PATH: ' . $trace[0]['file']; if (is_object($label)) { $label = 'CLASS: ' . get_class($label); } else { $label = $label === null ? '' : rtrim($label) . ' '; } $label = '<header style=" border-bottom: 2px solid #c99; color: #752201; cursor:pointer;" >' . ' <span class="arrow">↓</span> DEBUG: ' . $label . '</header>'; $output = Zend_Debug::dump($var, NULL, false); $output = '<article class="debug" style="margin: 1em; padding: 0 1em; background-color: #ddd;" >' . $label . '<section style="display:none">' . '<small>' . $l . '</small>' . $output . '</section>' . '</article>'; return $output; }
/** * Delete entries * * @param array|string $where SQL WHERE clause(s) * @return int|string */ public function delete($id) { $table = $this->getTable(); // Get the parent_role from the role will delete $role = $this->fetchEntry($id); //Zend_Debug::dump($role["role_parent"], "rol que eliminamos"); //find the roles have the parent role of the role will delete $rolsongs = $this->fetchParentRoles($id); // Zend_Debug::dump($rolsongs["0"]["id"], "el hijo del rol que eliminaremos"); //chance the parent_role of the songs foreach ($rolsongs as $value) { $data["role_parent"] = (int) $role["role_parent"]; $data["id"] = $value["id"]; $this->update($data, 'id =' . (int) $value["id"]); } //find the users with the role will delete $users = new User_Model_Users(); $users->getTable(); $arrayusers = $users->fetchUsers($id); //Zend_Debug::dump($arrayusers,"users with role will delete"); // chance the role to the users foreach ($arrayusers as $value) { $data["role_id"] = (int) $rolsongs["0"]["id"]; $data["id"] = $value["id"]; Zend_Debug::dump($data, "data1"); $users->update($data, 'id =' . (int) $value["id"]); } $table->delete('id =' . (int) $id); }
/** * Kann verwendet werden wenn es Probleme mit * * Solrsearch_IndexControllerTest;;testFacetSortForYearInverted * * gibt. Einfache am Anfang des tearDown in ControllerTestCase aufrufen. * * $assumption = new AssumptionChecker($this); * $assumption->checkYearFacetAssumption(); */ public function checkYearFacetAssumption() { $this->testCase->resetRequest(); $this->testCase->resetResponse(); $this->testCase->dispatch('/solrsearch/index/search/searchtype/all'); $searchStrings = array('2011', '2009', '2010', '1978', '2008', '2012', '1979', '1962', '1963', '1975'); $response = $this->testCase->getResponse()->getBody(); $startString = 'id="year_facet"'; $startPos = strpos($response, $startString); $this->testCase->assertFalse($startPos === false, "'{$startString}' not found, instead: {$response}"); $lastPos = $startPos; $loopComplete = true; for ($i = 0; $i < 10; $i++) { $lastPos = strpos($response, '>' . $searchStrings[$i] . '</a>', $lastPos); if ($lastPos === false) { Zend_Debug::dump("'" . $searchStrings[$i] . '\' not found in year facet list (iteration ' . $i . ')'); } $this->testCase->assertFalse($lastPos === false, "'" . $searchStrings[$i] . '\' not found in year facet list (iteration ' . $i . ')'); if ($lastPos === false) { break; $loopComplete = false; } } $this->testCase->assertTrue($loopComplete); }
function dump($dado, $stop = null) { Zend_Debug::dump($dado); if ($stop) { exit; } }
public function indexAction() { $agentSchemeNumber = $this->getRequest()->getParam('asn'); $agents = new Manager_Core_Agent(); $agent = $agents->getAgent($agentSchemeNumber); $this->view->tradingName = $agent->name; $this->view->schemeNumber = $agent->agentSchemeNumber; $this->view->commissionRate = $agent->commissionRate * 100; $this->view->newBusinessCommissionRate = $agent->newBusinessCommissionRate * 100; Zend_Debug::dump($agent->contact); foreach ($agent->contact as $contactDetails) { if ($contactDetails->category == Model_Core_Agent_ContactMapCategory::OFFICE) { // @todo Commented out to allow tests to run - repair /* $this->view->contactAddress1 = ''; if ($contactDetails->flatNumber) $this->view->contactAddressLine1 .= $contactDetails->flatNumber . ' '; if ($contactDetails->houseNumber) $this->view->contactAddressLine1 .= $contactDetails->houseNumber . ' '; if ($contactDetails->houseName) $this->view->contactAddressLine1 .= $contactDetails->houseName . ' '; if ($contactDetails->addressLine1) { $this->view->contactAddressLine1 .= $contactDetails->addressLine1 . ' '; $this->view->contactAddressLine2 = $contactDetails->addressLine2; } else { $this->view->contactAddressLine1 .= $contactDetails->addressLine2 . ' '; } */ $this->view->contactTown = $contactDetails->address->town; $this->view->contactPostcode = $contactDetails->address->postCode; } } Zend_Debug::dump($agent); }
public function indexAction() { // numero da semana anterior $zendDate = new Zend_Date(); $semana = $zendDate->get(Zend_Date::WEEK) - 1; $dia_semana = $zendDate->get(Zend_Date::WEEKDAY_DIGIT); $zendDate->subDay(7); $dia_semana_inicio = $dia_semana - 1; $dia_semana_fim = 7 - $dia_semana; $periodo_inicial = $zendDate->subDay($dia_semana_inicio)->get("dd/MM/YYYY"); $periodo_final = $zendDate->addDay($dia_semana_fim)->get('dd/MM/YYYY'); $periodo = $periodo_inicial . ' à ' . $periodo_final; // busca as visualizacoes da semana $modelSalaoVisualizacao = new Model_DbTable_SalaoVisualizacao(); $visualizacoes = $modelSalaoVisualizacao->visualizacoes($semana); try { foreach ($visualizacoes as $visualizacao) { $pluginMail = new Plugin_Mail(); $pluginMail->setDataMail('visualizacao', $visualizacao); $pluginMail->setDataMail('periodo', $periodo); $pluginMail->send("salao-visualizacao.phtml", "Relatório de Visualizações", $visualizacao->salao_email); } echo 'emails enviados'; } catch (Zend_Mail_Exception $ex) { die('email'); } catch (Exception $ex) { Zend_Debug::dump($ex->getMessage()); } }
/** Perform an uncached query for sparql using ARC2 * @access private * @param string $q SPARQL query to perform * @return array */ private function uncachedQuery($q) { $retrieve = $this->_arc2->getRemoteStore($this->_config); Zend_Debug::dump($retrieve); $response = $retrieve->query($q, 'rows'); return $response; }
public function applyFilterToCollection($value, $notUsingFieldForCompatibilityWithEnterprise = null) { $attribute = $this->getAttributeModel(); $collection = $this->getLayer()->getProductCollection(); if (Mage::helper('amshopby')->useSolr()) { $fieldName = Mage::getResourceSingleton('enterprise_search/engine')->getSearchEngineFieldName($attribute, 'nav'); $prefix = '{!tag=' . $attribute->getAttributeCode() . '}'; $collection->addFqFilter(array($prefix . $fieldName => $value)); } else { $alias = $this->_getAttributeTableAlias(); $connection = $this->_getResource()->getReadConnection(); if ($this->getUseAndLogic()) { foreach ($value as $i => $attrValue) { $alias = $alias . $i; $conditions = array("{$alias}.entity_id = e.entity_id", $connection->quoteInto("{$alias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$alias}.store_id = ?", $collection->getStoreId()), $connection->quoteInto("{$alias}.value = ?", $attrValue)); $collection->getSelect()->join(array($alias => $this->_getResource()->getMainTable()), join(' AND ', $conditions), array()); } } else { $conditions = array("{$alias}.entity_id = e.entity_id", $connection->quoteInto("{$alias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$alias}.store_id = ?", $collection->getStoreId()), $connection->quoteInto("{$alias}.value IN(?)", $value)); $collection->getSelect()->join(array($alias => $this->_getResource()->getMainTable()), join(' AND ', $conditions), array()); } } if (isset($_REQUEST['debug'])) { Zend_Debug::dump($collection->getSelect()->__toString()); } if (count($value) > 1) { $collection->getSelect()->distinct(true); } }
public function checkoutAction() { $params = $this->getRequest()->getParams(); $email = $params['email']; if (!$email) { return $this->_redirect('checkout/cart', array('_secure' => true)); } $websiteId = Mage::app()->getWebsite()->getId(); $store = Mage::app()->getStore(); $customer = Mage::getModel('customer/customer'); $customer->setWebsiteId($websiteId); $customer->setStore($store); $customer->loadByEmail($email); if (!$customer->getId()) { $CustomerName = explode('@', $email); $customer->setFirstname($CustomerName[0])->setLastname($CustomerName[0])->setEmail($email)->setPassword($customer->generatePassword()); $customer->sendPasswordReminderEmail(); try { $customer->save(); } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); } } $customerId = $customer->getId(); Mage::getSingleton('customer/session')->setCustomerId($customerId); $cart = $this->_getCart(); $cart->getQuote()->setCustomerId($customerId); $this->_redirect('checkout/onepage', array('_secure' => true)); }
public function indexAction() { $this->view->helpItemGateway = new Help_Model_HelpItemGateway(); $temp = $this->view->helpItemGateway->fetchHelpItems(); Zend_Debug::dump($temp); $this->view->helpItemList = Zend_Paginator::factory($temp); }
public function sendAction() { $message = new Push_Model_Message(); $now = Zend_Date::now()->toString('y-MM-dd HH:mm:ss'); $errors = array(); if ($id = $this->getRequest()->getParam('message_id')) { $message->find($id); $messages = array(); if ($message->getId() and $message->getStatus() == "queued") { $messages[] = $message; } } else { $messages = $message->findAll(array('status IN (?)' => array('queued'), 'send_at IS NULL OR send_at <= ?' => $now, 'send_until IS NULL OR send_until >= ?' => $now), 'created_at DESC'); } if (count($messages) > 0) { foreach ($messages as $message) { try { // Envoi et sauvegarde du message $message->push(); if ($message->getErrors()) { $errors[$message->getId()] = $message->getErrors(); } } catch (Exception $e) { $message->updateStatus('failed'); $errors[$message->getId()] = $e; } } } Zend_Debug::dump('Erreurs :'); Zend_Debug::dump($errors); die('done'); }
public function callbackAction() { //oAuth parameters $params = array('siteUrl' => 'http://ecschina.com/oauth', 'requestTokenUrl' => 'http://ecschina.com/oauth/initiate', 'accessTokenUrl' => 'http://ecschina.com/oauth/token', 'consumerKey' => 'ufs7anw8j9duj754vplvczyxmcdvor5b', 'consumerSecret' => 'i8mcujolcsglsx3egi2do10cmvelkly8'); // Get session $session = Mage::getSingleton('core/session'); // Read and unserialize request token from session $requestToken = unserialize($session->getRequestToken()); // Initiate oAuth consumer $consumer = new Zend_Oauth_Consumer($params); // Using oAuth parameters and request Token we got, get access token $acessToken = $consumer->getAccessToken($_GET, $requestToken); // Get HTTP client from access token object $restClient = $acessToken->getHttpClient($params); // Set REST resource URL $restClient->setUri('http://magento.loc/api/rest/products'); // In Magento it is neccesary to set json or xml headers in order to work $restClient->setHeaders('Accept', 'application/json'); // Get method $restClient->setMethod(Zend_Http_Client::GET); //Make REST request $response = $restClient->request(); // Here we can see that response body contains json list of products Zend_Debug::dump($response); return; }
/** * CallApi * * @param endPoint $endPoint partial end point url * @param params $params to be passed to api * @return array response from api or general error form this class */ public function callApi($endPoint, array $params) { /* check if end point is available prior to make request */ if (!in_array($endPoint, $this->endPoints)) { if (Mage::getSingleton("core/session")->getPsonifyDebug() == 'true') { echo "<br/><h1>End Point</h1><br/>"; echo $endPoint; echo "<br/><h1>Sent Params</h1><br/>"; Zend_Debug::dump($params); echo "<br/><h1>Received Result</h1><br/>"; Zend_Debug::Dump($this->getValidationErrorResponse('End point is not valid')); } return $this->getValidationErrorResponse('End point is not valid'); } else { $params["token"] = isset($params["token"]) ? $params["token"] : $params["data"]["token"]; /* initializing curl */ $ch = curl_init(); $curlConfig = array(CURLOPT_URL => $this->apiUrl . '/' . $endPoint, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => json_encode($params)); curl_setopt_array($ch, $curlConfig); $result = curl_exec($ch); if (Mage::getSingleton("core/session")->getPsonifyDebug() == 'true') { echo "<br/><h1>End Point</h1><br/>"; echo $endPoint; echo "<br/><h1>Sent Params</h1><br/>"; Zend_Debug::dump($params); echo "<br/><h1>Recieved Result</h1><br/>"; Zend_Debug::Dump($result); } curl_close($ch); return json_decode($result); } }
public function save(array $data) { $data_contact = $data; $data_user_company["companies_id"] = $data["company_id"]; $table = $this->getTable(); $fields = $table->info(Zend_Db_Table_Abstract::COLS); foreach ($data as $field => $value) { if (!in_array($field, $fields)) { unset($data[$field]); } } $data['password'] = hash('SHA256', $data['password']); $table->insert($data); $last_insert_id = $table->lastInsertId(); Zend_Debug::dump($data_contact); //check if the user want have contat $data_contact['acl_users_id'] = $last_insert_id; if ($data_contact["add_contact"]) { $model = new Company_Model_Contact(); $model->save($data_contact); } //Add the user in the company $data_user_company["acl_users_id"] = $data_contact['acl_users_id']; $db = Zend_Registry::get('db'); // Zend_Debug::dump($data_user_company); // die(); $db->insert(acl_users_has_companies, $data_user_company); return $last_insert_id; }