public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'creationdate', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Date'), 'title' => $translate->_('eg: 01/11/2010'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('text', 'expiringdate', array('filters' => array('StringTrim'), 'label' => $translate->_('Expiry Date'), 'title' => $translate->_('eg: 01/11/2011'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('text', 'paymentdate', array('filters' => array('StringTrim'), 'label' => $translate->_('Payment Date'), 'title' => $translate->_('eg: 01/11/2010'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat())); $this->addElement('select', 'category_id', array('label' => $translate->_('Category'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('category_id')->setAllowEmpty(false)->setMultiOptions(PurchaseCategories::getList()); $this->addElement('select', 'method_id', array('label' => $translate->_('Payment Method'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('method_id')->setAllowEmpty(false)->setMultiOptions(PaymentsMethods::getList()); $this->addElement('text', 'number', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Number'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'company', array('filters' => array('StringTrim'), 'label' => $translate->_('Company'), 'required' => true, 'title' => $translate->_('eg: Google inc.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'total_net', array('filters' => array('StringTrim'), 'label' => $translate->_('Total Net'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'total_vat', array('filters' => array('StringTrim'), 'label' => $translate->_('Total VAT'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('text', 'total', array('filters' => array('StringTrim'), 'label' => $translate->_('Total'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'label' => $translate->_('Note'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control')); // If the browser client is an Apple client hide the file upload html object if (false == Shineisp_Commons_Utilities::isAppleClient()) { $MBlimit = Settings::findbyParam('adminuploadlimit'); $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit); $filetypes = Settings::findbyParam('adminuploadfiletypes', 'Admin'); $file = $this->createElement('file', 'document', array('label' => $translate->_('Document'), 'decorators' => array('File', array('ViewScript', array('viewScript' => 'partials/file.phtml', 'placement' => false))), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $filetypes, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)), 'data-classButton' => 'btn btn-primary', 'data-input' => 'false', 'class' => 'filestyle')); $file->addValidator('Extension', false, $filetypes)->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1); $file->setValueDisabled(true); $file->setRequired(false); $this->addElement($file); } $this->addElement('select', 'status_id', array('label' => $translate->_('Status'), 'required' => true, 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->getElement('status_id')->setAllowEmpty(false)->setMultiOptions(Statuses::getList('orders')); $this->addElement('hidden', 'purchase_id'); }
/** * Save the setup data * @param array $dbconfig * @param array $preferences * * <?xml version="1.0" encoding="UTF-8"?> <shineisp> <config> <database> <hostname>localhost</hostname> <db>shineisp</db> <username>shineisp</username> <password>shineisp2013</password> </database> </config> </shineisp> */ public static function saveConfig($dbconfig, $version = null) { try { $xml = new SimpleXMLElement('<shineisp></shineisp>'); if (!empty($version)) { $xml->addAttribute('version', $version); } $xml->addAttribute('setupdate', date('Ymdhis')); $config = $xml->addChild('config'); // Database Configuration $database = $config->addChild('database'); $database->addChild('hostname', $dbconfig->hostname); $database->addChild('username', $dbconfig->username); $database->addChild('password', $dbconfig->password); $database->addChild('database', $dbconfig->database); // Get the xml string $xmlstring = $xml->asXML(); // Prettify and save the xml configuration $dom = new DOMDocument(); $dom->loadXML($xmlstring); $dom->formatOutput = true; $dom->saveXML(); // Save the config xml file if (@$dom->save(APPLICATION_PATH . "/configs/config.xml")) { Shineisp_Commons_Utilities::log("Update ShineISP config xml file"); return true; } else { throw new Exception("Error on saving the xml file in " . APPLICATION_PATH . "/configs/config.xml <br/>Please check the folder permissions"); } } catch (Exception $e) { throw new Exception($e->getMessage()); } return false; }
protected function checkFields() { parent::checkFields(); if ($this->amount == NULL) { throw new IgfsMissingParException("Missing amount"); } if ($this->refTranID == NULL) { if ($this->pan == NULL) { if ($this->payInstrToken == NULL) { Shineisp_Commons_Utilities::logs("---> Missing refTranID", 'bnl_igfs.log'); } } } return false; if ($this->pan != NULL) { // Se è stato impostato il pan verifico... if ($this->pan == "") { Shineisp_Commons_Utilities::logs("---> Missing pan", 'bnl_igfs.log'); } return false; } if ($this->payInstrToken != NULL) { // Se è stato impostato il payInstrToken verifico... if ($this->payInstrToken == "") { Shineisp_Commons_Utilities::logs("---> Missing payInstrToken", 'bnl_igfs.log'); } return false; } if ($this->pan != NULL or $this->payInstrToken != NULL) { if ($this->currencyCode == NULL) { Shineisp_Commons_Utilities::logs("---> Missing currencyCode", 'bnl_igfs.log'); } return false; } }
public function init() { $NS = new Zend_Session_Namespace('Default'); $translate = Shineisp_Registry::get('Zend_Translate'); // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $this->addElement('select', 'domain_id', array('decorators' => array('Bootstrap'), 'required' => false, 'label' => $translate->_('Domain'), 'description' => $translate->_('Choose the domain name reference'), 'class' => 'form-control large-input')); $this->getElement('domain_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Domains::getList(true, $NS->customer['customer_id'])); $this->addElement('text', 'subject', array('filters' => array('StringTrim'), 'required' => false, 'decorators' => array('Bootstrap'), 'title' => $translate->_('Write here a subject of the issue.'), 'label' => $translate->_('Subject'), 'description' => $translate->_('Write here the domain name or a simple description of the problem.'), 'class' => 'form-control large-input')); $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'label' => $translate->_('Body Message'), 'decorators' => array('Bootstrap'), 'description' => $translate->_('Write here all the information.'), 'rows' => '8', 'class' => 'form-control wysiwyg-simple')); $this->addElement('select', 'status', array('filters' => array('StringTrim'), 'label' => $translate->_('Set the issue status'), 'decorators' => array('Bootstrap'), 'class' => 'form-control large-input', 'multioptions' => array('' => '', Statuses::id("solved", "tickets") => $translate->_('Solved'), Statuses::id("closed", "tickets") => $translate->_('Closed')))); $this->addElement('select', 'category_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Category'), 'description' => 'Select a category.', 'class' => 'form-control large-input')); $this->getElement('category_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(TicketsCategories::getList(true)); if (false == Shineisp_Commons_Utilities::isAppleClient()) { $MBlimit = Settings::findbyParam('useruploadlimit'); $Types = Settings::findbyParam('useruploadfiletypes'); if (empty($MBlimit)) { $MBlimit = 1; } if (empty($Types)) { $Types = "zip,jpg"; } $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit); $file = $this->createElement('file', 'attachments', array('label' => $translate->_('Attachment'), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $Types, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)))); $file->addValidator('Extension', false, $Types)->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1); $this->addElement($file); } else { $this->addElement('hidden', 'attachments'); } $this->addElement('submit', 'submit', array('label' => $translate->_('Send help request'), 'decorators' => array('Bootstrap'), 'class' => 'btn btn-primary btn-lg')); $this->addElement('hidden', 'ticket_id'); }
/** * callbackAction * This method isn't called from the project * but it is called from a bank gateway service * in order to set as payed the order processed * * IMPORTANT: * This method was within the /default/orders controller and it has been moved here * because the access to the /default/orders is denied without an authentication process * /default/common controller is accessible without login process. */ public function callbackAction() { $request = $this->getRequest(); $response = $request->getParams(); if (!empty($response['custom']) && is_numeric(trim($response['custom']))) { // Getting the md5 value in order to match with the class name. $classrequest = $request->gateway; // Orderid back from the bank $order_id = trim($response['custom']); // Get the bank selected using the MD5 code $bank = Banks::findbyMD5($classrequest); if (!empty($bank[0]['classname'])) { if (!empty($bank[0]['classname']) && class_exists($bank[0]['classname'])) { $class = $bank[0]['classname']; $payment = new $class($response['custom']); // Check if the method "Response" exists in the Payment class and send all the bank information to the payment module if (method_exists($class, "Response")) { Shineisp_Commons_Utilities::logs("Callback called: {$class}\nParameters: " . json_encode($response), "payments.log"); $payment->Callback($response); } } } } die; }
public function preStmtExecute(Doctrine_Event $event) { // Check if the administrator has enabled the query logging feature if (Settings::findbyParam('debug_queries')) { $breadcrumps = array(); $query = $event->getQuery(); $params = $event->getParams(); $callers = array_reverse(debug_backtrace(), true); $callers = array_slice($callers, 4, count($callers) - 10); foreach ($callers as $caller) { $class = !empty($caller['class']) ? $caller['class'] : null; $breadcrumps[] = $class . "->" . $caller['function']; } $strBreadcrump = "System: " . implode(" / ", $breadcrumps); //the below makes some naive assumptions about the queries being logged while (sizeof($params) > 0) { $param = array_shift($params); if (!is_numeric($param)) { $param = sprintf("'%s'", $param); } $query = substr_replace($query, $param, strpos($query, '?'), 1); } Shineisp_Commons_Utilities::log($query, "queries.log"); Shineisp_Commons_Utilities::log($strBreadcrump, "debug.log", Zend_Log::DEBUG); // Increase query counter $queryCount = Shineisp_Registry::isRegistered('querycount') ? Shineisp_Registry::get('querycount') : 0; $queryCount = $queryCount + 1; Shineisp_Registry::set('querycount', $queryCount); } }
private function eu_check() { $isp = Shineisp_Registry::get('ISP'); $VIES = new SoapClient($this->vies_soap_url); if ($VIES) { try { $r = $VIES->checkVat(array('countryCode' => $this->countryCode, 'vatNumber' => $this->vat)); foreach ($r as $chiave => $valore) { $this->viesOutput[$chiave] = $valore; } return $r->valid; } catch (SoapFault $e) { $ret = $e->faultstring; $regex = '/\\{ \'([A-Z_]*)\' \\}/'; $n = preg_match($regex, $ret, $matches); $ret = !empty($matches[1]) ? $matches[1] : $ret; $faults = array('INVALID_INPUT' => 'The provided CountryCode is invalid or the VAT number is empty', 'SERVICE_UNAVAILABLE' => 'The SOAP service is unavailable, try again later', 'MS_UNAVAILABLE' => 'The Member State service is unavailable, try again later or with another Member State', 'TIMEOUT' => 'The Member State service could not be reached in time, try again later or with another Member State', 'SERVER_BUSY' => 'The service cannot process your request. Try again later.'); $ret = $faults[$ret]; // adding a log message Shineisp_Commons_Utilities::log("Response from VIES: " . $ret); $subject = 'Invalid VAT code'; $body = "Response from VIES: " . $ret; Shineisp_Commons_Utilities::SendEmail($isp->email, $isp->email, null, $subject, $body); return false; } } else { $subject = 'Connect to VIES'; $body = "Impossible to connect with VIES"; Shineisp_Commons_Utilities::SendEmail($isp->email, $isp->email, null, $subject, $body); // adding a log message Shineisp_Commons_Utilities::log("Response from VIES: " . $ret); return false; } return true; }
/** * showblock * Handle the XML Blocks * @param unknown_type $side */ public function showblock($side) { $ns = new Zend_Session_Namespace('Admin'); $languageID = Languages::get_language_id($ns->lang); $record = array(); $blocks = array(); // Get the main variables $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $action = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); $customskin = Settings::findbyParam('adminskin'); $skin = !empty($customskin) ? $customskin : "base"; // call the placeholder view helper for each side parsed echo $this->view->placeholder($side); // Get all the xml blocks $xmlblocks = Shineisp_Commons_Layout::getBlocks($module, $side, $controller, $skin); if (!empty($xmlblocks)) { $blocks['reference'] = $xmlblocks; } if (!empty($blocks['reference'])) { $blocks['reference'] = Shineisp_Commons_Utilities::columnSort($blocks['reference'], 'position'); } if (isset($blocks['reference']['block'])) { $this->Iterator($blocks['reference'], $side); } elseif (isset($blocks['reference'][0])) { foreach ($blocks['reference'] as $block) { $this->Iterator($block, $side); } } $this->view->module = $module; $this->view->controller = $controller; $this->view->action = $action; }
public function errorAction() { $errors = $this->_getParam('error_handler'); $mex = $this->_getParam('mex'); // Ajax controll if (Shineisp_Commons_Utilities::isAjax()) { echo json_encode($errors->exception->getMessage()); die; } switch ($errors->type) { case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: // 404 error -- controller or action not found $this->getResponse()->setHttpResponseCode(404); $this->view->message = 'Controller has been not found'; break; case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: // 404 error -- controller or action not found $this->getResponse()->setHttpResponseCode(404); $this->view->message = 'Action has been not found'; break; default: // application error $this->getResponse()->setHttpResponseCode(500); $this->view->message = $errors->exception->getMessage(); break; } if (!empty($mex)) { $this->view->message .= "<br/><b>{$mex}</b>"; } // Save the error message in the log file errors.log $errormessage = $errors->type . ": " . $errors->exception->getMessage(); Shineisp_Commons_Utilities::log($errormessage); $this->view->exception = $errors->exception; $this->view->request = $errors->request; }
public function init() { $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $this->addElement('select', 'locale', array('decorators' => array('Bootstrap'), 'label' => 'Language', 'class' => 'form-control', 'multioptions' => Languages::getLanguageFiles(PUBLIC_PATH . "/languages"))); $this->addElement('textarea', 'agreement', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'label' => 'Agreements', 'rows' => '10', 'value' => Shineisp_Commons_Utilities::readfile(PUBLIC_PATH . "/../LICENSE"))); $this->addElement('select', 'chkagreement', array('decorators' => array('Bootstrap'), 'label' => 'I agree with the legal terms', 'class' => 'form-control', 'multioptions' => array(1 => 'YES, I agree with the legal terms', 0 => 'NO, I disagree with these legal terms'))); $this->addElement('submit', 'submit', array('label' => 'Continue', 'decorators' => array('Bootstrap'), 'class' => 'btn btn-primary btn-lg')); }
protected function checkFields() { parent::checkFields(); if ($this->shopID == NULL || "" == $this->shopID) { Shineisp_Commons_Utilities::logs("---> Missing shopID", 'bnl_igfs.log'); } return false; }
public function gravatar($email, $width = 60) { if (!is_numeric($width)) { $width = 60; } if (Shineisp_Commons_Utilities::isEmail($email)) { return Shineisp_Commons_Gravatar::get_gravatar($email, $width); } return false; }
protected function checkFields() { parent::checkFields(); if ($this->amount == NULL) { Shineisp_Commons_Utilities::logs("---> Missing amount", 'bnl_igfs.log'); } return false; if ($this->refTranID == NULL) { Shineisp_Commons_Utilities::logs("---> Missing refTranID", 'bnl_igfs.log'); } return false; }
/** * Load all the resources * @see Zend_Controller_Action::preDispatch() */ public function indexAction() { $session = new Zend_Session_Namespace('setup'); $session->permissions = false; $dirs = array(); $errors = array(); $applicationfolder = true; $publicfolder = true; $dirs[] = PUBLIC_PATH; $dirs[] = PUBLIC_PATH . "/media/"; $dirs[] = PUBLIC_PATH . "/documents/"; $dirs[] = PUBLIC_PATH . "/logs/"; $dirs[] = PUBLIC_PATH . "/imports/"; $dirs[] = PUBLIC_PATH . "/tmp/"; $dirs[] = PUBLIC_PATH . "/cache/"; $dirs[] = APPLICATION_PATH . "/configs/"; $dirs[] = APPLICATION_PATH . "/configs/data/"; $dirs[] = APPLICATION_PATH . "/configs/data/sql/"; // create all the directories foreach ($dirs as $dir) { if (!is_dir($dir)) { if (!@mkdir($dir)) { $errors[] = $dir; } } else { if (!Shineisp_Commons_Utilities::isWritable($dir)) { $errors[] = $dir; } } } // check the public directory if (Shineisp_Commons_Utilities::isWritable(PUBLIC_PATH)) { $this->view->public_folder = true; } else { $this->view->public_folder = false; $publicfolder = false; } // check the application config data directory if (Shineisp_Commons_Utilities::isWritable(APPLICATION_PATH . "/configs/data/")) { $this->view->application_folder = true; } else { $this->view->application_folder = false; $applicationfolder = false; } $this->view->errors = $errors; if ($publicfolder & $applicationfolder && count($errors) == 0) { $session->permissions = true; $this->_helper->redirector('index', 'localization', 'setup'); } else { return $this->_helper->viewRenderer('index'); } }
/** * Export the products by the Google Product Atom Export * @author Shine Software * @return xml */ public function googleproductsAction() { // Calling Google Product Extension Zend_Feed_Writer::addPrefixPath('Shineisp_Feed_Writer_Extension_', 'Shineisp/Feed/Writer/Extension/'); Zend_Feed_Writer::registerExtension('Google'); $isp = Shineisp_Registry::get('ISP'); $feed = new Zend_Feed_Writer_Feed(); $feed->setTitle($isp->company); $feed->setLink($isp->website); $feed->setFeedLink($isp->website . '/atom/products', 'atom'); $feed->addAuthor(array('name' => $isp->manager, 'email' => $isp->email, 'uri' => $isp->website)); $feed->setDateModified(time()); $feed->setGenerator("ShineISP Atom Extension"); $products = Products::getAllRss(); // print_r($products); // die; foreach ($products as $product) { // Get the google categories $categories = ProductsCategories::getGoogleCategories($product['categories']); $cattype = Products::get_text_categories($product['categories']); // Create the product entries $entry = $feed->createEntry(); $entry->setTitle($product['ProductsData'][0]['name']); $entry->setProductType(Products::get_text_categories($product['categories'])); $entry->setBrand($isp->company); $entry->setAvailability(true); $entry->setLink($isp->website . "/" . $product['uri'] . ".html"); // Custom Attributes Google Product Extension if (!empty($product['ProductsMedia'][0]['path'])) { $entry->setImageLink($isp->website . str_replace(" ", "%20", $product['ProductsMedia'][0]['path'])); } if (!empty($product['uri'])) { $entry->setProductId($product['uri']); } if (!empty($categories[0]['googlecategs'])) { $entry->setCategory($categories[0]['googlecategs']); } $price = Products::getPriceSuggested($product['product_id'], true); $entry->setPrice($price); $entry->setCondition('new'); $entry->setDateModified(time()); $entry->setDescription(strip_tags($product['ProductsData'][0]['shortdescription'])); $feed->addEntry($entry); } $feed = $feed->export('atom'); // Feed Fixing for google products $feed = $this->googlefixes($feed); Shineisp_Commons_Utilities::writefile($feed, "documents", "googleproducts.xml"); die($feed); }
public function indexAction() { $NS = new Zend_Session_Namespace('Default'); if (!empty($NS->customer)) { $this->view->dashboard = true; } else { $this->view->dashboard = false; } $this->view->mex = $this->getRequest()->getParam('mex'); $this->view->mexstatus = $this->getRequest()->getParam('status'); $this->view->customer = $NS->customer; $this->view->headTitle()->prepend($NS->customer['lastname'] . " " . $NS->customer['firstname']); // Clean up the tmp folder Shineisp_Commons_Utilities::cleantmp(); }
/** * Get all statuses * * @return object $statuses */ public static function getAll() { $out = array(); $records = Doctrine_Query::create()->from('Statuses s')->execute(array(), Doctrine_Core::HYDRATE_ARRAY); // normalize data foreach ($records as $record) { $section = strtolower($record['section']); $code = strtolower($record['code']); // code as key $out[$section][$code] = $record; // status_id as key $out['id:' . $record['status_id']] = $record; // PHP BUG: See Statuses::getById } return Shineisp_Commons_Utilities::array2object($out); }
/** * Add one or more entries. Note that entries must * be manually added once created. */ private function createEntry($feed, $title, $descritption, $link, $dateCreated = null, $dateModified = null) { if (!empty($title)) { $entry = $feed->createEntry(); $entry->setTitle($title); if (!empty($descritption)) { $descritption = strip_tags($descritption); $entry->setDescription(Shineisp_Commons_Utilities::CropSentence($descritption, 300, "...")); } $entry->setLink($link); $entry->setDateModified(!empty($dateModified) ? $dateModified : time()); $entry->setDateCreated(!empty($dateCreated) ? $dateCreated : time()); $feed->addEntry($entry); } return $feed; }
public function simplegrid($data) { $this->view->module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $this->view->controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $this->view->action = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); if (isset($data['records'])) { // Name of the table, useful for the jQuery pager $this->view->name = !empty($data['name']) ? $data['name'] : "table_" . Shineisp_Commons_Uuid::generate(); // Index of the table $this->view->id = !empty($this->view->fields[0]) && is_numeric($data['records'][0][$this->view->fields[0]]) ? $data['records'][0][$this->view->fields[0]] : "0"; // All the records $this->view->records = $data['records']; // Create the header using the field name if the columns variable is not set if (empty($data['columns'])) { $data['columns'] = array(); if (!empty($data['records'][0])) { // Get all the fields $items = Shineisp_Commons_Utilities::array_flatten($data['records'][0]); $fields = array_keys($items); foreach ($fields as $field) { if (strpos($field, "_id") === false) { // When a record is called using the HYDRATE_SCALAR mode the table aliases are attached in the field name // In this way we delete the first part of the field name. For instance: o_name --> name $arrfield = explode("_", $field); $field = count($arrfield) > 0 ? $arrfield[count($arrfield) - 1] : $field; $data['columns'][] = ucfirst(Shineisp_Registry::getInstance()->Zend_Translate->translate($field)); } } } } $this->view->columns = $data['columns']; // If these options are true a link appear for each row in a table $this->view->view = !empty($data['view']) ? $data['view'] : false; $this->view->edit = !empty($data['edit']) ? $data['edit'] : false; $this->view->delete = !empty($data['delete']) ? $data['delete'] : false; $this->view->targetlink = !empty($data['targetlink']) ? $data['targetlink'] : null; // If you need more action use this parameter Array{'url'=>'name'} // for instance $actions['/admin/customers'] = "Customers"; // the label customers will be translated $this->view->actions = !empty($data['actions']) ? $data['actions'] : false; $this->view->onclick = !empty($data['onclick']) ? $data['onclick'] : false; } else { $this->view->records = ""; } // Path of the template return $this->view->render('partials/simplegrid.phtml'); }
public function preDispatch(Zend_Controller_Request_Abstract $request) { $this->_init($request); // echo Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName(); // Zend_Debug::dump(Zend_Controller_Front::getInstance()->getRequest()->getParams()); // if the current user role is not allowed to do something $resource = $this->_module . ":" . $this->_controller; $allowed_resources[] = "default:error"; $allowed_resources[] = "api:index"; $allowed_resources[] = "api:request"; $allowed_resources[] = "admin:index"; $allowed_resources[] = "admin:login"; $allowed_resources[] = "system:index"; $allowed_resources[] = "system:cron"; $allowed_resources[] = "system:tasks"; $allowed_resources[] = "setup:index"; $allowed_resources[] = "setup:checker"; $allowed_resources[] = "setup:database"; $allowed_resources[] = "setup:localization"; $allowed_resources[] = "setup:preferences"; $allowed_resources[] = "setup:summary"; // Exclude the system index controller and the default error controller for a formal ACL check if (in_array($resource, $allowed_resources)) { return true; } // Zend_Debug::dump($resource); // Zend_Debug::dump($this->_currentRole); // Check if the user is an Administrator and let him free to access to all the resources if ($this->_currentRole == "administrator") { return true; } if ($this->_currentRole == "guest" && $this->_module == "default") { return true; } if (!$this->_acl->isAllowed($this->_currentRole, $resource, "allow")) { if ('guest' == $this->_currentRole) { Shineisp_Commons_Utilities::log("Login: The role '" . $this->_currentRole . "' has not sufficient permissions to access the resource '{$resource}'. The user has been redirected to the login page."); $request->setControllerName('login'); $request->setActionName('index'); } else { Shineisp_Commons_Utilities::log("Login: The role '" . $this->_currentRole . "' is not allowed to access to the {$resource}. It is redirected to the no authentication page."); $request->setControllerName('login'); $request->setActionName('noauth'); } } }
public function productsAction() { $ns = new Zend_Session_Namespace(); $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><shineisp></shineisp>'); $localeID = $ns->idlang; $products = $xml->addChild('products'); try { // Get all the products $records = Products::getAll(null, $localeID); if (!empty($records)) { foreach ($records as $item) { $item['ProductsData'][0]['shortdescription'] = strip_tags($item['ProductsData'][0]['shortdescription']); $item['ProductsData'][0]['description'] = strip_tags($item['ProductsData'][0]['description']); $item['ProductsData'][0]['shortdescription'] = html_entity_decode($item['ProductsData'][0]['shortdescription'], ENT_NOQUOTES, "UTF-8"); $item['ProductsData'][0]['description'] = html_entity_decode($item['ProductsData'][0]['description'], ENT_NOQUOTES, "UTF-8"); $item['ProductsData'][0]['shortdescription'] = str_replace("&", "", $item['ProductsData'][0]['shortdescription']); $item['ProductsData'][0]['description'] = str_replace("&", "", $item['ProductsData'][0]['description']); $categories = products::get_text_categories($item['categories']); $categories = htmlspecialchars($categories); $product = $products->addChild('product'); $product->addAttribute('uuid', $item['uuid']); $product->addAttribute('id', $item['product_id']); $product->addAttribute('inserted_at', !empty($item['inserted_at']) ? strtotime($item['inserted_at']) : null); $product->addAttribute('updated_at', !empty($item['updated_at']) ? strtotime($item['updated_at']) : null); $product->addChild('sku', htmlentities($item['sku'])); if (!empty($item['ProductsMedia'][0]['path']) && file_exists(PUBLIC_PATH . $item['ProductsMedia'][0]['path'])) { $product->addChild('image', "http://" . $_SERVER['HTTP_HOST'] . $item['ProductsMedia'][0]['path']); } $product->addChild('name', !empty($item['ProductsData'][0]['name']) ? $item['ProductsData'][0]['name'] : null); $product->addChild('shortdescription', !empty($item['ProductsData'][0]['shortdescription']) ? "<![CDATA[" . $item['ProductsData'][0]['shortdescription'] . "]]>" : null); $product->addChild('description', !empty($item['ProductsData'][0]['description']) ? "<![CDATA[" . $item['ProductsData'][0]['description'] . "]]>" : null); $product->addChild('categories', $categories); $price = $product->addChild('price', Products::getPrice($item['product_id'])); $price->addAttribute('taxincluded', 0); $price->addAttribute('isrecurrent', products::isRecurring($item['product_id'])); $price->addAttribute('currency', Settings::findbyParam('currency')); } } header('Content-Type: text/xml; charset=utf-8'); die($xml->asXML()); } catch (Exception $e) { Shineisp_Commons_Utilities::log(__CLASS__ . " " . $e->getMessage()); die; } }
function _isRecompileNeeded($cache_file) { // If there is no cache file, we obviously need to recompile. if (!file_exists($cache_file)) { return true; } $cache_mtime = filemtime($cache_file); // If the source files are newer than the cache file, recompile. foreach ($this->_srcs as $src) { if (filemtime($src) > $cache_mtime) { Shineisp_Commons_Utilities::log("Updating CSS Cache: {$src} must be updated."); return true; } } // Cache is up to date. Shineisp_Commons_Utilities::log("CSS Cache is up to date."); return false; }
/** * Main public function that create the pdf file */ public function create($data, $filename = "file.pdf", $show = true) { // Add the data $this->data = $data; // Create the pdf page $this->create_page(); // Create the datagrid $this->create_grid(); // Get PDF document as a string $contents = $this->pdf->render(); header("Content-type: application/x-pdf"); $tmpname = Shineisp_Commons_Utilities::GenerateRandomString(); @mkdir(PUBLIC_PATH . "/tmp/"); $file = fopen(PUBLIC_PATH . "/tmp/" . $tmpname . ".pdf", 'a+'); fputs($file, $contents); fclose($file); return json_encode(array('url' => "/tmp/" . $tmpname . ".pdf")); }
public function listAction() { $ns = new Zend_Session_Namespace(); $products = array(); // get the category uri $uri = $this->getRequest()->getParam('q'); if (!empty($uri)) { // Save the path of the user $ns->lastcategory = $uri; // Get the category information $category = $this->categories->getAllInfobyURI($uri); if (!empty($category[0])) { $this->view->category = $category[0]; // Get the subcategories $this->view->subcategory = ProductsCategories::getbyParentId($category[0]['category_id'], 1, true); // Set the Metatag information $this->view->headTitle()->prepend($category[0]['name']); if (!empty($category[0]['keywords'])) { $this->view->headMeta()->setName('keywords', $category[0]['keywords']); } if (!empty($category[0]['description'])) { $this->view->headMeta()->setName('description', $category[0]['description'] ? Shineisp_Commons_Utilities::truncate(strip_tags($category[0]['description'])) : '-'); } $this->view->headertitle = $category[0]['name']; // Get the products information $fields = "pd.productdata_id as productdata_id, \n\t\t\t\t pd.name as name, \n\t\t\t\t pd.shortdescription as shortdescription, \n\t\t\t\t pd.metakeywords as metakeywords, \n\t\t\t\t pd.metadescription as metadescription, \n\t\t\t\t p.*, pag.code as groupcode"; $data = $this->categories->getProductListbyCatUri($uri, $fields, $ns->langid); if (!empty($data['records'])) { // Get the media information for each product foreach ($data['records'] as $product) { $product['reviews'] = Reviews::countItems($product['product_id']); $product['attributes'] = ProductsAttributes::getAttributebyProductID($product['product_id'], $ns->langid, true); $products[] = $product; } $this->view->products = $products; $this->view->pager = $data['pager']; } $this->view->layoutmode = !empty($ns->layoutmode) ? $ns->layoutmode : "list"; $this->_helper->viewRenderer($ns->layoutmode); } else { $this->_helper->redirector('index', 'index', 'default'); } } }
public function init() { // Set the custom decorator $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator'); $translate = Shineisp_Registry::get('Zend_Translate'); $this->addElement('text', 'subject', array('filters' => array('StringTrim'), 'required' => false, 'decorators' => array('Bootstrap'), 'label' => $translate->_('Subject'), 'class' => 'form-control')); $this->addElement('text', 'datetime', array('filters' => array('StringTrim'), 'label' => $translate->_('Date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control')); $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'class' => 'col-lg-12 form-control wysiwyg')); $this->addElement('select', 'sendemail', array('label' => $translate->_('Send Email'), 'description' => $translate->_('Send an email to the customer.'), 'decorators' => array('Bootstrap'), 'class' => 'form-control', 'multioptions' => array('1' => $translate->_('Yes'), '0' => $translate->_('No')))); $this->addElement('select', 'category_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Category'), 'class' => 'form-control')); $this->getElement('category_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(TicketsCategories::getList()); $this->addElement('select', 'customer_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Customer'), 'class' => 'form-control')); $this->getElement('customer_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Customers::getList()); $this->addElement('select', 'category', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Category'), 'class' => 'form-control')); $this->getElement('category')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(TicketsCategories::getList()); $this->addElement('select', 'order_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Order reference'), 'class' => 'form-control')); $this->getElement('order_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Orders::getList(true)); $this->addElement('select', 'sibling_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Relationships'), 'class' => 'form-control')); $this->getElement('sibling_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false); $this->addElement('select', 'user_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Operator'), 'class' => 'form-control')); $this->getElement('user_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(AdminUser::getList()); #->setMultiOptions(AdminUser::getUserbyRoleID(AdminRoles::getIdRoleByName('operator'))); $this->addElement('select', 'status_id', array('decorators' => array('Bootstrap'), 'label' => $translate->_('Status'), 'class' => 'form-control')); $this->getElement('status_id')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Statuses::getList('tickets')); // If the browser client is an Apple client hide the file upload html object if (false == Shineisp_Commons_Utilities::isAppleClient()) { $MBlimit = Settings::findbyParam('adminuploadlimit'); $Types = Settings::findbyParam('adminuploadfiletypes', 'Admin'); if (empty($MBlimit)) { $MBlimit = 1; } if (empty($Types)) { $Types = "zip,jpg"; } $Byteslimit = Shineisp_Commons_Utilities::MB2Bytes($MBlimit); $file = $this->createElement('file', 'attachments', array('label' => $translate->_('Attachment'), 'decorators' => array('File', array('ViewScript', array('viewScript' => 'partials/file.phtml', 'placement' => false))), 'description' => $translate->_('Select the document to upload. Files allowed are (%s) - Max %s', $Types, Shineisp_Commons_Utilities::formatSizeUnits($Byteslimit)), 'data-classButton' => 'btn btn-primary', 'data-input' => 'false', 'class' => 'filestyle')); $file->addValidator('Extension', false, $Types)->addValidator('Size', false, $Byteslimit)->addValidator('Count', false, 1); $this->addElement($file); } else { $this->addElement('hidden', 'attachments'); } $this->addElement('hidden', 'ticket_id'); }
public function init() { try { // Store logged ISP. I'm in the public area, se we use only the URL $ISP = Isp::findByUrl($_SERVER['HTTP_HOST']); if (!empty($ISP)) { Shineisp_Registry::set('ISP', $ISP); } // Load all the status in the registry $statusreg = Shineisp_Registry::get('Status'); if (empty($statusreg)) { $status = Statuses::getAll(); Shineisp_Registry::set('Status', $status); } } catch (Exception $e) { Shineisp_Commons_Utilities::log(__METHOD__ . " " . $e->getMessage()); } parent::init(); }
public function Grid($data) { $this->view->module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $this->view->controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $this->view->action = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); // Create the header using the field name if the columns variable is not set if (empty($data['columns'])) { $data['columns'] = array(); if (!empty($data['records'][0])) { // Get all the fields $items = Shineisp_Commons_Utilities::array_flatten($data['records'][0]); $fields = array_keys($items); foreach ($fields as $field) { if (strpos($field, "_id") === false) { // When a record is called using the HYDRATE_SCALAR mode the table aliases are attached in the field name // In this way we delete the first part of the field name. For instance: o_name --> name $arrfield = explode("_", $field); $field = count($arrfield) > 0 ? $arrfield[count($arrfield) - 1] : $field; $data['columns'][] = ucfirst(Shineisp_Registry::getInstance()->Zend_Translate->translate($field)); } } } } $this->view->columns = $data['columns']; if (isset($data['records']) && count($data['records']) > 0) { $this->view->fields = array_keys($data['records'][0]); $this->view->id = !empty($this->view->fields[0]) && is_numeric($data['records'][0][$this->view->fields[0]]) ? $data['records'][0][$this->view->fields[0]] : "0"; $this->view->numcols = count($this->view->fields); $this->view->records = $data['records']; $this->view->currentpage = $data['currentpage']; $this->view->pagination = $data['pagination']; $this->view->customactions = isset($data['customactions']) ? $data['customactions'] : array(); $this->view->show_action_box = !isset($data['show_action_box']) ? true : $data['show_action_box']; } $this->view->recordcount = !empty($data['recordcount']) ? $data['recordcount'] : 0; $this->view->statuses = isset($data['statuses']) ? $data['statuses'] : array(); $this->view->filters = isset($data['filters']) ? $data['filters'] : array(); $this->view->tags = isset($data['tags']) ? $data['tags'] : array(); return $this->view->render('partials/grid.phtml'); }
public function indexAction() { $auth = Zend_Auth::getInstance(); $registry = Shineisp_Registry::getInstance(); $translation = Shineisp_Registry::get('Zend_Translate'); $retval = array(); if ($auth->hasIdentity()) { $request = Zend_Controller_Front::getInstance()->getRequest(); try { $form = new Admin_Form_BulkmailForm(array('action' => '/admin/bulkmail/#bulkmail', 'method' => 'post')); if ($request->isPost()) { $isp = Isp::getActiveISP(); if ($form->isValid($request->getPost())) { $data = $request->getPost(); $mail = new Bulkmails(); $mail->subject = $data['subject']; $mail->body = $data['body']; $mail->senddate = date('Y-m-d H:i:s'); $mail->save(); $customers = Customers::getEmails(); foreach ($customers as $customer) { $body = str_replace('{fullname}', $customer['fullname'], $data['body']); $result = Shineisp_Commons_Utilities::SendEmail($isp['email'], $customer['email'], null, $data['subject'], $body, true); if ($result !== true) { $retval[] = $result; } } } } $retval = count($retval) > 0 ? $retval : null; $this->view->form = $form; $this->view->title = $translation->translate("Mass eMail"); $this->view->description = $translation->translate("Write here a message to send to all your own customers."); $this->view->errors = $retval; } catch (Exception $e) { die($e->getMessage()); } } }
public function processAction() { $ns = new Zend_Session_Namespace("default"); $request = $this->getRequest(); $form = new Default_Form_ContactsForm(array('action' => '/contacts/process', 'method' => 'post')); $this->view->form = $form; // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('index', 'contacts', 'default'); } if ($form->isValid($request->getPost())) { // Get the values posted $params = $form->getValues(); $captcha = $params['captcha']; // Actually it's an array, so both the ID and the submitted word // is in it with the corresponding keys // So here's the ID... $captchaId = $captcha['id']; // And here's the user submitted word... $captchaInput = $captcha['input']; // We are accessing the session with the corresponding namespace // Try overwriting this, hah! $captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_' . $captchaId); // To access what's inside the session, we need the Iterator // So we get one... $captchaIterator = $captchaSession->getIterator(); // And here's the correct word which is on the image... $captchaWord = $captchaIterator['word']; // Now just compare them... if ($captchaInput == $captchaWord) { $isp = Shineisp_Registry::get('ISP'); Shineisp_Commons_Utilities::sendEmailTemplate($isp->email, 'contact', array('fullname' => $params['fullname'], 'company' => $params['company'], 'email' => $params['email'], 'subject' => $params['subject'], 'message' => $params['message']), null, null, null, null, $ns->langid); // Redirect the visitor to the contact page return $this->_helper->redirector('index', 'contacts', 'default', array('mex' => 'The task requested has been executed successfully.', 'status' => 'success')); } } return $this->_helper->viewRenderer('index'); }
/** * Export the sample data */ public function dataexportAction() { $dsn = Shineisp_Main::getDSN(); $conn = Doctrine_Manager::connection($dsn, 'doctrine'); $conn->execute('SHOW TABLES'); # Lazy loading of the connection. If I execute a simple command the connection to the database starts. $conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true); $conn->setCharset('UTF8'); // clean up the fixture directory Shineisp_Commons_Utilities::delTree(APPLICATION_PATH . "/configs/data/fixtures/"); @mkdir(APPLICATION_PATH . "/configs/data/fixtures/"); // Set the current connection $manager = Doctrine_Manager::getInstance()->setCurrentConnection('doctrine'); if ($conn->isConnected()) { #Doctrine_Core::dumpData(APPLICATION_PATH . "/configs/data/fixtures/", false); $export = new Doctrine_Data_Export(APPLICATION_PATH . "/configs/data/fixtures/"); $export->setFormat('yml'); $export->setModels(array()); $export->exportIndividualFiles(true); $export->doExport(); } die('done'); }