/** * @return AM_Mapper_Sqlite_Element */ protected function _unmapCustom() { $sContentText = null; $oElementDataSet = $this->getModel()->getResources(); /* @var $oElementDataSet AM_Model_Db_Element_Data_Abstract */ foreach ($oElementDataSet->getData() as $oElementData) { /* @var $oElementData AM_Model_Db_Element_Data_Abstract */ if (AM_Model_Db_Element_Data_Resource::PDF_INFO == $oElementData->key_name) { if (!empty($oElementData->value)) { $aPdfInfo = Zend_Json_Decoder::decode($oElementData->value, true); $sContentText = $aPdfInfo['text']; } } $sElementDataMapperClassName = self::ELEMENT_DATA_MAPPER_CLASS_PREFIX . Zend_Filter::filterStatic($oElementData->key_name, 'Word_UnderscoreToCamelCase'); if (class_exists($sElementDataMapperClassName, true)) { $oElementDataMapper = new $sElementDataMapperClassName($oElementData, array('adapter' => $this->_getAdapter())); $oElementDataMapper->unmap(); continue; } $aData = array('element_id' => $this->getModel()->id, 'type' => $oElementData->key_name, 'value' => $oElementDataSet->getDataValueForExport($oElementData->key_name), 'position_id' => 0); $this->_getSqliteGateway('element_data')->insert($aData); } $aData = array('id' => $this->getModel()->id, 'page_id' => $this->getModel()->page, 'element_type_name' => $this->getModel()->getFieldTypeTitle(), 'weight' => intval($this->getModel()->weight), 'content_text' => $sContentText); $this->_getSqliteGateway()->insert($aData); return $this; }
/** * Action more. * * @return void */ public function moreAction() { $page = Zend_Filter::filterStatic($this->_getParam('page'), 'int'); $identity = Zend_Auth::getInstance()->getIdentity(); $courses = Application_Model_Classroom::getAllByUser($identity->id); $this->view->timeline = Application_Model_Timeline::getByClassroom($courses, $page); }
public function viewAction() { $identity = Zend_Auth::getInstance()->getIdentity(); $id = Zend_Filter::filterStatic($this->_getParam('id'), 'int'); $exerciseId = Zend_Filter::filterStatic($this->_getParam('exerciseId'), 'int'); $userId = Zend_Filter::filterStatic($this->_getParam('userId', $identity->id), 'int'); $exercise = new Tri_Db_Table('exercise'); $exerciseQuestion = new Tri_Db_Table('exercise_question'); $exerciseNote = new Tri_Db_Table('exercise_note'); $exerciseAnswer = new Tri_Db_Table('exercise_answer'); if ($id) { $note = $exerciseNote->fetchRow(array('id = ?' => $id)); } elseif ($exerciseId) { $note = $exerciseNote->fetchRow(array('exercise_id = ?' => $exerciseId, 'user_id = ?' => $userId), 'id DESC'); } if ($note) { $row = $exercise->fetchRow(array('id = ?' => $note->exercise_id)); if ($row) { $where = array('exercise_id = ?' => $row->id, 'status = ?' => 'active'); $this->view->questions = $exerciseQuestion->fetchAll($where); $this->view->exercise = $row; $this->view->answers = $exerciseAnswer->fetchAll(array('exercise_note_id = ?' => $note->id)); $this->view->note = $note; $whereNote = array('exercise_id = ?' => $note->exercise_id, 'id <> ?' => $note->id, 'user_id = ?' => $userId); $this->view->notes = $exerciseNote->fetchAll($whereNote, 'id DESC'); $this->view->userId = $userId; } else { $this->view->message = 'there are no records'; } } else { $this->view->message = 'there are no records'; } }
public function date($value, $displayTime = false) { if ($displayTime) { $translate = Zend_Registry::get('Zend_Translate'); $locale = key(Zend_Registry::get('Zend_Locale')->getDefault()); $date = new Zend_Date($value, null, $locale); if ($date->isToday()) { $h = $date->toString('H'); $m = $date->toString('m'); $s = $date->toString('s'); if (date('H') == $h) { $min = (int) date('i') - (int) $m; if ($min < 1) { $sec = (int) date('s') - (int) $s; if ($sec < 10) { return $translate->_('now'); } return $sec . ' ' . $translate->_('seconds ago'); } return $min . ' ' . $translate->_('minutes ago'); } elseif (date('H') > $h) { return (int) date('H') - (int) $h . ' ' . $translate->_('hours ago'); } return $date->toString('H:m'); } else { return $date->toString('dd/MM/y H:m'); } } return Zend_Filter::filterStatic($value, 'date', array(), 'Tri_Filter'); }
public function filter($value) { $digits = Zend_Filter::filterStatic($value, 'Digits'); $padded = str_pad($digits, 5, '0', STR_PAD_LEFT); $output = 'HRS' . $padded; return $output; }
public function __call($function, $args) { $re = '/(' . join('|', array_keys(array_map('preg_quote', $this->_queryTypes))) . ')(.+?)(?:By(.+))*$/'; if (preg_match($re, $function, $matches)) { $queryType = $matches[1]; if (isset($this->_queryTypes[$queryType])) { $temp = str_split($matches[2]); $temp[0] = strtolower($temp[0]); $method_names = array('_' . $queryType . $matches[2] . 'Query', '_' . join($temp) . 'Query'); $queryMethod = $this->_queryTypes[$queryType]; if (isset($matches[3])) { array_unshift($method_names, '_' . $queryType . $matches[2] . 'ByQuery'); if (Zend_Version::compareVersion('1.7.9') < 0) { $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $field = strtolower($filter->filter($matches[3])); } else { $field = strtolower(Zend_Filter::filterStatic($matches[3], 'Word_CamelCaseToUnderscore')); } array_unshift($args, $field); } foreach ($method_names as $method) { if (method_exists($this, $method)) { $sql = call_user_func_array(array($this, $method), $args); return $this->{$queryMethod}($sql); break; } } die("Cannot find proper query method for function <b>" . $function . "</b> of class " . get_class($this)); } } de('Table.php: ', $function, $args); return parent::__call($function, $args); }
public function postSave($entity, $dto = NULL) { $data = $dto->getMap(); unset($data['sqUsuarioExterno']); $entityPF = $this->_getRepository('app:UsuarioPessoaFisica')->find($entity->getSqUsuarioExterno()); $data['sqTipoEscolaridade'] = NULL; $data['sqPaisOrigem'] = NULL; if ($dto->getSqTipoEscolaridade()) { $data['sqTipoEscolaridade'] = $this->_getRepository('app:TipoEscolaridade')->find($dto->getSqTipoEscolaridade()); } if ($dto->getSqPaisOrigem()) { $data['sqPaisOrigem'] = $this->_getRepository('app:Pais')->find($dto->getSqPaisOrigem()); } if ($entityPF) { $entityPF->fromArray($data); } else { $entityPF = \Core_Dto::factoryFromData($dto->getMap(), 'entity', $this->_entityOption)->getEntity(); $entityPF->setSqTipoEscolaridade($data['sqTipoEscolaridade']); $entityPF->setSqPaisOrigem($data['sqPaisOrigem']); } $entityPF->setNuCpf(\Zend_Filter::filterStatic($entityPF->getNuCpf(), 'Digits')); $entityPF->setSqUsuarioExterno($entity); $this->getEntityManager()->persist($entityPF); $this->getEntityManager()->flush($entityPF); parent::postSave($entity, $dto); }
public static function filterStatic($value, $classBaseName, array $args = array(), $namespaces = array()) { $namespaces = array_merge(array('Kwf_Filter'), (array) $namespaces); class_exists('Kwf_Filter_' . ucfirst($classBaseName)); //trigger autoloader return parent::filterStatic($value, $classBaseName, $args, $namespaces); }
/** * * @param La_Db_Table $table * @param La_Form $form */ public function direct(La_Db_Table $table = null, La_Form $form = null) { $controller = $this->getActionController(); $id = Zend_Filter::filterStatic($controller->getParam("id"), 'int'); $ajaxContext = $controller->getHelper('AjaxContext'); $formData = $controller->getParam("formData"); $ajaxContext->addActionContext('form', 'html')->initContext(); if (!$form) { $form = $controller->form; } if (!$table) { $table = $controller->table; } $table->setAutoJoin(false); $controller->view->data = $table->createRow(); if ($id) { $row = $table->find($id)->current(); if (!$row) { $controller->view->messages = array($controller->getHelper('Message')->direct('ERROR_LOAD')); } else { $controller->view->data = $row; $form->populate($row->toArray()); if ($formData) { $form->populate($formData); $controller->view->messages = array($controller->getHelper('Message')->direct('ERROR', true)); } } } $controller->view->dynamicFormId = uniqid(); $controller->view->form = $form; $controller->view->id = $id; }
/** * * @param La_Db_Table $table */ public function direct(La_Db_Table $table = null, $redirectUrl = null) { $controller = $this->getActionController(); $data = $this->getRequest()->getParams(); $table = $table ?: $controller->table; $url = sprintf('%s/%s/index/parent_id/%s/table/%s', $data['module'], $data['controller'], $data['parent_id'], $table->getName()); if (!$table) { $table = $controller->table; } if ($redirectUrl) { $url = $redirectUrl; } $id = $data['id']; if ($id) { $ids = (array) $id; try { foreach ($ids as $id) { $where = array('id = ?' => Zend_Filter::filterStatic($id, 'int')); $table->logicDelete($where); } $message = $controller->getHelper('Message')->direct('SUCCESS'); $controller->redirect($url); } catch (Exception $e) { $message = $controller->getHelper('Message')->direct('ERROR_DELETE'); $controller->redirect($url); } } $message = $controller->getHelper('Message')->direct('ERROR_DELETE'); $controller->redirect($url); }
public function splitTelephone($telephone) { $telephone = Zend_Filter::filterStatic($telephone, 'Digits'); $ddd = substr($telephone, 0, 2); $number = substr($telephone, 2); $data = array('ddd' => $ddd, 'number' => $number); return $data; }
/** * * @param Zend_Db_Select|Zend_Db_Table_Select $select * @return \La_Paginator */ public function direct(Zend_Db_Select $select) { $request = $this->getRequest(); $page = Zend_Filter::filterStatic($request->getParam('page', 1), 'int'); $quantity = Zend_Filter::filterStatic($request->getParam('quantity', 10), 'int'); $paginator = new La_Paginator($select, $page, $quantity); return $paginator->getResult(); }
public function saveAction() { $session = new Zend_Session_Namespace('data'); $userId = Zend_Filter::filterStatic($this->_getParam('userId'), 'int'); Panel_Model_Certificate::emit($userId, $session->classroom_id); $this->_helper->_flashMessenger->addMessage('Success'); $this->_redirect('/panel'); }
/** * return select table content * * @param int $discipline => id discipline * @param mixed $columns => columns apresentation select * @param null|int $content => id content * @access private * @return object Zend_Db_Table_Select */ private function mountSelect($discipline, $columns, $content_id = null) { $content = new Content_Model_Content(); $select = $content->select()->setIntegrityCheck(false)->from(array("tcs" => "content"), $columns, 'trails')->where("tcs.discipline_id = ?", Zend_Filter::filterStatic($discipline, 'Int'))->order(array("tcs.content_id", "tcs.position", "tcs.id")); if ($content_id) { $select->join(array("tc" => "trails.content"), "tcs.id = tc.content_id", array())->where("( tcs.content_id = ?", $content_id)->orWhere("tcs.id = ? )", $content_id); } return $select; }
public function saveTelefoneSgdoce($entity, $entityAux1) { $telefone = $this->getServiceLocator()->getService('VwTelefone')->findTelefone($entity->getSqPessoa()); $entityTelefoneArtefato = NULL; $filter = new \Zend_Filter(); if ($telefone->getSqTelefone()) { $entityTelefoneArtefato = $this->_newEntity('app:TelefoneSgdoce'); $tipoTelefone = $this->getEntityManager()->getPartialReference('app:VwTipoTelefone', \Core_Configuration::getSgdoceTipoTelefoneResidencial()); $entityTelefoneArtefato->setSqPessoaSgdoce($entityAux1); $entityTelefoneArtefato->setSqTipoTelefone($tipoTelefone); $entityTelefoneArtefato->setDtCadastro(new \Zend_Date()); $entityTelefoneArtefato->setNuDdd($filter->filterStatic($telefone->getNuDdd(), 'Digits')); $entityTelefoneArtefato->setNuTelefone($filter->filterStatic($telefone->getNuTelefone(), 'Digits')); $this->getEntityManager()->persist($entityTelefoneArtefato); } $this->getEntityManager()->flush($entityTelefoneArtefato); return $entityTelefoneArtefato; }
/** * método que seta os objetos */ public function setOperationalEntity($entityName = NULL) { $this->_data['sqUnidadeOrg'] = $this->_createEntityManaged(array('sqUnidadeOrg' => $this->_data['sqPessoa']), 'app:VwUnidadeOrg'); $this->_data['sqTipoArtefato'] = $this->_createEntityManaged(array('sqTipoArtefato' => $this->_data['sqTipoArtefato']), 'app:TipoArtefato'); if (!empty($this->_data['sqTipoDocumento'])) { $this->_data['sqTipoDocumento'] = \Zend_Filter::filterStatic($this->_data['sqTipoDocumento'], 'null'); $this->_data['sqTipoDocumento'] = $this->_createEntityManaged(array('sqTipoDocumento' => $this->_data['sqTipoDocumento']), 'app:TipoDocumento'); } }
public function replyAction() { $receiverId = Zend_Filter::filterStatic($this->_getParam('receiverId'), 'int'); $form = new Chat_Form_Message(); $form->populate(array('receiver' => $receiverId)); $form->populate(array('sender' => Zend_Auth::getInstance()->getIdentity()->id)); $this->view->form = $form; $this->render('reply'); }
protected function _callSetterMethod($property, $data) { $method = Zend_Filter::filterStatic($property, 'Word_UnderscoreToCamelCase'); $methodName = '_set' . $method; if (method_exists($this, $methodName)) { return $this->{$methodName}($data); } else { return self::NO_SETTER; } }
public function deleteAction() { $table = new Tri_Db_Table('glossary'); $id = Zend_Filter::filterStatic($this->_getParam('id'), 'int'); if ($id) { $table->delete(array('id = ?' => $id)); $this->_helper->_flashMessenger->addMessage('Success'); } $this->_redirect('glossary/index/'); }
public function deleteAction() { $calendar = new Zend_Db_Table('calendar'); $id = Zend_Filter::filterStatic($this->_getParam('id'), 'int'); if (!$id) { $this->_redirect('calendar/index/'); } $calendar->delete(array('id = ?' => $id)); $this->_helper->_flashMessenger->addMessage('Success'); $this->_redirect('calendar/index/'); }
public function deleteAction() { $table = new Tri_Db_Table('content_file'); $id = Zend_Filter::filterStatic($this->_getParam('id'), 'int'); $location = $this->_getParam('location'); @unlink(APPLICATION_PATH . '/../data/upload/' . $location); if ($id) { $table->delete(array('id = ?' => $id)); $this->_helper->_flashMessenger->addMessage('Success'); } $this->_redirect('content/file/index/'); }
/** * Formats a value using the mask passed * * Ex: mask(12345678, '####-####); * * @param type $value * @param type $mask * @return type */ public function mask($value, $mask) { $output = Zend_Filter::filterStatic($value, 'Alnum'); $index = -1; $len = strlen($mask); for ($i = 0; $i < $len; ++$i) { if ($mask[$i] == '#' && isset($output[++$index])) { $mask[$i] = $output[$index]; } } return $mask; }
public function viewAction() { $id = Zend_Filter::filterStatic($this->_getParam('id'), 'int'); if ($id) { $course = new Tri_Db_Table('course'); $classroom = new Tri_Db_Table('classroom'); $this->view->data = $course->find($id)->current(); $where = array('course_id = ?' => $id, 'status = ?' => 'open', 'end >= ? OR end IS NULL' => date('Y-m-d')); $this->view->classroom = $classroom->fetchAll($where, 'begin'); $this->view->selectionProcess = SelectionProcess_Model_SelectionProcess::getAvailableProcessByCourse($id); } }
/** * Action form * * @return void */ public function formAction() { $id = Zend_Filter::filterStatic($this->_getParam('id'), 'int'); $form = new Admin_Form_Course(); if ($id) { $table = new Tri_Db_Table('course'); $row = $table->find($id)->current(); if ($row) { $form->populate($row->toArray()); } } $this->view->form = $form; }
/** * Create mapper object * @param AM_Model_Db_Abstract $oModel * @param string $sProvider * @param array $aOptions * @return AM_Mapper_Abstract */ public static final function factory(AM_Model_Db_Abstract $oModel, $sProvider, $aOptions = array()) { $sModelTableName = $oModel->getTableName(); $sProvider = ucfirst(Zend_Filter::filterStatic($sProvider, 'Word_UnderscoreToCamelCase')); $sModelTableName = ucfirst(Zend_Filter::filterStatic($sModelTableName, 'Word_UnderscoreToCamelCase')); $sMapperClassName = 'AM_Mapper_' . $sProvider . "_" . $sModelTableName; $sFile = str_replace('_', DIRECTORY_SEPARATOR, $sMapperClassName) . '.php'; if (!AM_Tools_Standard::isReadable($sFile)) { throw new AM_Mapper_Exception(sprintf('Mapper class "%s" not found', $sMapperClassName), 503); } $oMapper = new $sMapperClassName($oModel, $aOptions); return $oMapper; }
public function _place(Mage_Sales_Model_Order_Payment $payment, $amount) { try { $order = $payment->getOrder(); $azpay = new AZPay($this->_merchantId, $this->_merchantKey); $azpay->curl_timeout = 60; $azpay->config_order['reference'] = $order->getRealOrderId(); $azpay->config_order['totalAmount'] = Mage::helper('azpay')->formatAmount($amount); $azpay->config_options['urlReturn'] = Mage::getUrl('azpay/transaction_boleto/postback'); /*$azpay->config_boleto['acquirer'] = $this->getConfigData('operator'); $azpay->config_boleto['expire'] = $this->_generateExpirationDate(); $azpay->config_boleto['nrDocument'] = substr($order->getRealOrderId(), 1); $azpay->config_boleto['amount'] = Mage::helper('azpay')->formatAmount($amount); $azpay->config_boleto['instructions'] = $this->getConfigData('instructions');*/ $azpay->config_online_debit['acquirer'] = $this->getConfigData('operator'); $billingAddress = $order->getBillingAddress(); if ($order->getCustomerTaxvat()) { $azpay->config_billing['customerIdentity'] = $order->getCustomerTaxvat(); } else { $azpay->config_billing['customerIdentity'] = $order->getRealOrderId(); } $azpay->config_billing['name'] = $order->getCustomerName(); $azpay->config_billing['address'] = $billingAddress->getStreet(1) . ',' . $billingAddress->getStreet(2); $azpay->config_billing['address2'] = $billingAddress->getStreet(3) ? $billingAddress->getStreet(3) : ''; $azpay->config_billing['city'] = $billingAddress->getCity(); $azpay->config_billing['state'] = $billingAddress->getRegionCode(); $azpay->config_billing['postalCode'] = Zend_Filter::filterStatic($billingAddress->getPostcode(), 'Digits'); $azpay->config_billing['phone'] = Mage::helper('azpay')->splitTelephone($billingAddress->getTelephone()); $azpay->config_billing['email'] = $order->getCustomerEmail(); $azpay->config_options['urlReturn'] = Mage::getUrl('azpay/transaction_boleto/postback'); // Execute $azpay->online_debit()->execute(); $azpay->getXml(); // usado para salvar o XML gerado no log // Log if ($this->getConfigData('log')) { Mage::log($azpay, null, "azpay_boleto.log"); } } catch (AZPay_Error $e) { Mage::log($e->getMessage(), null, "azpay_boleto_error.log"); $error = $azpay->responseError(); return Mage::throwException("Ocorreu um problema com o seu pedido. Tente novamente ou entre em contato conosco informando este código: " . $error['status_message']); } // Response $gateway_response = $azpay->response(); $paymentDetails['azpayboletourl'] = (string) $gateway_response->processor->Transfer->urlTransfer; $payment->setAdditionalData(serialize($paymentDetails)); // azpay info $payment->setAzpayTransactionId($gateway_response->transactionId)->setAzpayBoletoUrl((string) $gateway_response->processor->Transfer->urlTransfer); return $this; }
/** * Auxilia na criação das dependências da entidade * @access public * @param string $entityName */ public function setOperationalEntity($entityName = NULL) { if ($this->_data['inPrazoObrigatorio'] == 'TRUE') { $this->_data['nuDiasPrazo'] = ''; $this->_data['inDiasCorridos'] = ''; } $this->_data['sqTipoDocumento'] = \Zend_Filter::filterStatic($this->_data['sqTipoDocumento'], 'null'); if ($this->_data['sqTipoDocumento']) { $this->_data['sqTipoDocumento'] = $this->_createEntityManaged(array('sqTipoDocumento' => $this->_data['sqTipoDocumento']), 'app:TipoDocumento'); } $this->_data['sqAssunto'] = $this->_createEntityManaged(array('sqAssunto' => $this->_data['sqAssunto']), 'app:Assunto'); $this->_data['nuDiasPrazo'] = \Zend_Filter::filterStatic($this->_data['nuDiasPrazo'], 'null'); $this->_data['inDiasCorridos'] = \Zend_Filter::filterStatic($this->_data['inDiasCorridos'], 'null'); }
/** * Grabs users friends from the Graph * @param string $fbid The Facebook ID of the user * @param bool $onlyPlaying Only return friends who are using the app? * @param bool $resetCache Empty any data in the session cache? * @return array */ public function getUserFriends($fbid, $onlyPlaying = false, $resetCache = false, $notPlaying = false) { $fql = "SELECT uid, has_added_app FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = {$fbid})"; $data = $this->_doFQLQuery($fql, $resetCache); $return = array(); if (!empty($data) && is_array($data)) { foreach ($data as $d) { if (!$onlyPlaying && !$notPlaying || $onlyPlaying && $d->has_added_app || !$onlyPlaying && $notPlaying && !$d->has_added_app) { $return[] = (string) Zend_Filter::filterStatic($d->uid, 'Digits'); } } } return (array) $return; }
/** * Efetua a consulta para popular a grid. * @param array $params * @return \Doctrine\ORM\QueryBuilder */ public function searchIndicacaoPrazo($params) { $queryBuilder = $this->_em->createQueryBuilder(); $queryBuilder->select('ip', 'tp', 'a')->from('app:IndicacaoPrazo', 'ip')->leftJoin('ip.sqTipoDocumento', 'tp')->innerJoin('ip.sqAssunto', 'a'); if ($params->getSqTipoDocumento() && $params->getSqTipoDocumento_autocomplete()) { $sqTipoDocumento = \Zend_Filter::filterStatic($params->getSqTipoDocumento(), 'null'); $queryBuilder->andWhere('ip.sqTipoDocumento = :sqTipoDocumento')->setParameter('sqTipoDocumento', $sqTipoDocumento); } if ($params->getSqAssunto() && $params->getSqAssunto_autocomplete()) { $sqAssunto = \Zend_Filter::filterStatic($params->getSqAssunto(), 'null'); $queryBuilder->andWhere('ip.sqAssunto = :sqAssunto')->setParameter('sqAssunto', $sqAssunto); } return $queryBuilder; }
/** * Get APNS feedback service * @return ApnsPHP_Feedback */ public function getFeedbackService() { if (is_null($this->_oFeedbackService)) { $iApplicationId = intval($this->getOption('application_id')); if (empty($iApplicationId)) { throw new AM_Task_Worker_Exception('Wrong application id given'); } $sEnvironment = $this->getConfig()->apns->environment; $sCertificateRootPath = rtrim($this->getConfig()->apns->cerificate_path, DIRECTORY_SEPARATOR); $sCertificateRootPath .= DIRECTORY_SEPARATOR . $iApplicationId . '_' . $sEnvironment . '.pem'; $this->_oFeedbackService = new ApnsPHP_Feedback(constant('ApnsPHP_Abstract::' . Zend_Filter::filterStatic('ENVIRONMENT_' . $sEnvironment, 'StringToUpper')), $sCertificateRootPath); } return $this->_oFeedbackService; }