function upgrade_module_1_5_1($module)
{
    if (Hook::getIdByName('displayPaymentEu')) {
        return true;
    }
    $new_hook = new Hook();
    $new_hook->name = 'displayPaymentEu';
    $new_hook->title = 'Display EU payment options (helper)';
    $new_hook->description = 'Hook to display payment options';
    $new_hook->position = true;
    $new_hook->live_edit = false;
    return (bool) $new_hook->add() && (bool) $module->registerModulesBackwardCompatHook();
}
 private function checkOwnerHooks()
 {
     $hookspos = array('displayTop', 'displayHeaderRight', 'displaySlideshow', 'topNavigation', 'displayPromoteTop', 'displayRightColumn', 'displayLeftColumn', 'displayHome', 'displayFooter', 'displayBottom', 'displayContentBottom', 'displayFootNav', 'displayFooterTop', 'displayFooterBottom');
     foreach ($hookspos as $hook) {
         if (Hook::getIdByName($hook)) {
         } else {
             $new_hook = new Hook();
             $new_hook->name = pSQL($hook);
             $new_hook->title = pSQL($hook);
             $new_hook->add();
         }
     }
     return true;
 }
Beispiel #3
0
 function install()
 {
     if (Hook::get('orderAddressVerification') == false) {
         $hook = new Hook();
         $hook->name = 'orderAddressVerification';
         $hook->title = 'Order address verificatio';
         $hook->description = 'Allows modules to verify delivery and billing address in an order, e.g. require them to be in the same country';
         $hook->add();
     }
     if (parent::install() == false) {
         return false;
     }
     return true;
 }
Beispiel #4
0
 function install()
 {
     if (Hook::get('orderPages') == false) {
         $hook = new Hook();
         $hook->name = 'orderPages';
         $hook->title = 'Order process pages';
         $hook->description = 'Adds new pages in the order process';
         $hook->add();
     }
     if (parent::install() == false or $this->registerHook('orderPages') == false) {
         return false;
     }
     return true;
 }
 function install()
 {
     if (Hook::get('orderPriceAdjustment') == false) {
         $hook = new Hook();
         $hook->name = 'orderPriceAdjustment';
         $hook->title = 'Order price adjustment';
         $hook->description = 'Allows modules to adjust prices in an order after the user has logged in and registered an address, e.g. allows prices based on group memberships and the like.';
         $hook->add();
     }
     if (parent::install() == false) {
         return false;
     }
     return true;
 }
 public function hookFooter($params)
 {
     if (!$this->isCached('blockmyaccountfooter.tpl', $this->getCacheId())) {
         $this->smarty->assign(array('voucherAllowed' => CartRule::isFeatureActive(), 'returnAllowed' => (int) Configuration::get('PS_ORDER_RETURN'), 'HOOK_BLOCK_MY_ACCOUNT' => Hook::exec('displayMyAccountBlockfooter')));
     }
     return $this->display(__FILE__, 'blockmyaccountfooter.tpl', $this->getCacheId());
 }
Beispiel #7
0
 /**
  * 运行框架
  */
 public static function run()
 {
     try {
         self::init();
         Hook::init(BASE_PATH);
         Hook::listen('appBegin');
         Hook::listen('routeParseUrl', array(Config::get('REWRITE_RULE'), Config::get('REWRITE_ON')));
         //default route
         if (!defined('APP_NAME') || !defined('CONTROLLER_NAME') || !defined('ACTION_NAME')) {
             Route::parseUrl(Config::get('REWRITE_RULE'), Config::get('REWRITE_ON'));
         }
         //execute action
         $controller = '\\app\\' . APP_NAME . '\\controller\\' . CONTROLLER_NAME . 'Controller';
         $action = ACTION_NAME;
         if (!class_exists($controller)) {
             throw new \Exception("Controller '{$controller}' not found", 404);
         }
         $obj = new $controller();
         if (!method_exists($obj, $action)) {
             throw new \Exception("Action '{$controller}::{$action}()' not found", 404);
         }
         Hook::listen('actionBefore', array($obj, $action));
         $obj->{$action}();
         Hook::listen('actionAfter', array($obj, $action));
     } catch (\Exception $e) {
         Hook::listen('appError', array($e));
     }
     Hook::listen('appEnd');
 }
Beispiel #8
0
 /**
  * Create page
  *
  * @param array $val
  * @return \App\Models\Page
  */
 public function create($val)
 {
     $expected = ['title', 'description', 'website', 'url' => '', 'category'];
     /**
      * @var $title
      * @var $description
      * @var $website
      * @var $category
      * @var $url
      */
     extract(array_merge($expected, $val));
     if (!empty($title) and !empty($category)) {
         $page = $this->model->newInstance();
         $page->title = sanitizeText($title, 130);
         $page->slug = sanitizeText($url);
         $page->user_id = \Auth::user()->id;
         $page->description = \Hook::fire('filter-text', sanitizeText($description));
         $page->category_id = sanitizeText($category);
         $page->website = sanitizeText($website);
         $page->save();
         $page->save();
         $this->event->fire('page.add', [$page]);
         return $page;
     }
     return false;
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->addJS(_THEME_JS_DIR_ . 'index.js');
     $this->context->smarty->assign(array('HOOK_HOME' => Hook::exec('displayHome'), 'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'), 'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent')));
     $this->setTemplate(_PS_THEME_DIR_ . 'index.tpl');
 }
Beispiel #10
0
 public function builder()
 {
     $this->load->model('admin/admin_menu');
     $this->load->add_package_path(APPPATH . 'third_party/scrud/');
     $var = array();
     $_GET['crud_components'] = 'crud_components';
     $var['main_menu'] = $this->admin_menu->fetch('tool');
     $conf = array();
     if (!file_exists(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/crud_components.php')) {
         exit;
     } else {
         require __DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/crud_components.php';
     }
     $hook = Hook::singleton();
     $hook->addFunction('SCRUD_ADD_FORM', 'addTableElement');
     $hook->addFunction('SCRUD_EDIT_FORM', 'addTableElement');
     $hook->addFunction('SCRUD_ADD_CONFIRM', 'addTableElement');
     $hook->addFunction('SCRUD_EDIT_CONFIRM', 'addTableElement');
     $hook->addFunction('SCRUD_VIEW_FORM', 'addTableElement');
     $hook->addFunction('SCRUD_CONFRIM_DELETE_FORM', 'addTableElement');
     $hook->addFunction('SCRUD_BEFORE_UPDATE', 'removeConfig');
     $hook->addFunction('SCRUD_BEFORE_SAVE', 'checkGroup');
     $hook->addFunction('SCRUD_COMPLETE_DELETE', 'completeDelete');
     $conf['theme_path'] = FCPATH . 'application/views/admin/component/templates/builder';
     $this->load->library('crud', array('table' => 'crud_components', 'conf' => $conf));
     $var['main_content'] = $this->load->view('admin/component/builder', array('content' => $this->crud->process()), true);
     $this->load->model('admin/admin_footer');
     $var['main_footer'] = $this->admin_footer->fetch();
     $this->load->view('layouts/admin/scrud/browse', $var);
 }
Beispiel #11
0
	public function setDeliveryNumber($order_invoice_id, $id_shop)
	{
		if (!$order_invoice_id)
			return false;

		$number = Configuration::get('PS_DELIVERY_NUMBER', null, null, $id_shop);
		// If invoice start number has been set, you clean the value of this configuration
		if ($number)
			Configuration::updateValue('PS_DELIVERY_NUMBER', false, false, null, $id_shop);
			
		$order_invoice = new OrderInvoice($order_invoice_id);
		$order = new Order($order_invoice->id_order);
		$cart = new Cart($order->id_cart);
		
		if($ref = Hook::exec('actionBeforeAddDeliveryNumber', array('order'=>$order,'cart'=>$cart,'number'=>$number)))
			$number = $ref;

		$sql = 'UPDATE `'._DB_PREFIX_.'order_invoice` SET delivery_number =';

		if ($number)
			$sql .= (int)$number;
		else
			$sql .= '(SELECT new_number FROM (SELECT (MAX(`delivery_number`) + 1) AS new_number
			FROM `'._DB_PREFIX_.'order_invoice`) AS result)';

		$sql .=' WHERE `id_order_invoice` = '.(int)$order_invoice_id;

		return Db::getInstance()->execute($sql);
	}
 private function loadAddons()
 {
     $data = S('hooks');
     if (!$data) {
         $hooks = M('hooks')->getField('name,addons', true);
         foreach ($hooks as $key => $value) {
             if ($value) {
                 $map['status'] = 1;
                 $names = explode(',', $value);
                 $map['name'] = array('IN', $names);
                 $data = M('Addons')->where($map)->getField('id,name');
                 if ($data) {
                     $addons = array_intersect($names, $data);
                     Hook::add($key, $addons);
                 }
             }
         }
         S('hooks', Hook::get());
         //插件标签
         $tpl_tags = array();
         $data = M('addons')->getField('id,name');
         if ($data) {
             foreach ($data as $addon) {
                 if (is_file("HDCMS/Addons/{$addon}/Tag/{$addon}Tag.class.php")) {
                     $tpl_tags[] = "@.Addons.{$addon}.Tag.{$addon}Tag";
                 }
             }
         }
         S('HookTag', array_unique($tpl_tags));
     } else {
         Hook::import($data, false);
         C('TPL_TAGS', array_unique(array_merge(C('TPL_TAGS'), S('HookTag'))));
     }
 }
Beispiel #13
0
 public function index()
 {
     $this->load->model('crud_auth');
     $this->load->model('admin/admin_menu');
     $this->load->model('user/user_menu');
     $this->load->add_package_path(APPPATH . 'third_party/scrud/');
     $crudAuth = $this->session->userdata('CRUD_AUTH');
     $var = array();
     $conf = array();
     $var['main_menu'] = $this->admin_menu->fetch('account');
     $hook = Hook::singleton();
     $hook->addFunction('SCRUD_EDIT_FORM', 'removeElement');
     $hook->addFunction('SCRUD_EDIT_CONFIRM', 'removeElement');
     $hook->addFunction('SCRUD_BEFORE_VALIDATE', 'removeValidate');
     $hook->addFunction('SCRUD_COMPLETE_UPDATE', 'completeUpdate');
     $hook->addFunction('SCRUD_BEFORE_SAVE', 'removeElementData');
     if (!isset($_GET['xtype'])) {
         $_GET['xtype'] = 'form';
     }
     $_GET['table'] = 'crud_users';
     $_GET['key']['crud_users.id'] = $crudAuth['id'];
     $_SERVER['QUERY_STRING'] = $_SERVER['QUERY_STRING'] . '&key[crud_users.id]=' . $crudAuth['id'];
     if (!file_exists(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/' . $this->input->get('table') . '.php')) {
         exit;
     } else {
         require __DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/' . $this->input->get('table') . '.php';
     }
     $conf['theme_path'] = FCPATH . 'application/views/user/profile/crud';
     $this->load->library('crud', array('table' => $this->input->get('table'), 'conf' => $conf));
     $var['main_content'] = $this->load->view('user/profile/profile', array('content' => $this->crud->process(), 'user_menu' => $this->user_menu->fetch('profile')), true);
     $this->load->model('admin/admin_footer');
     $var['main_footer'] = $this->admin_footer->fetch();
     $this->load->view('layouts/user/default', $var);
 }
Beispiel #14
0
 /**
  * Initialize a cURL session.
  *
  * @return Recipe_HTTP_Session_Curl
  */
 protected function init()
 {
     $this->resource = @curl_init();
     if (!$this->resource) {
         throw new Recipe_Exception_Generic("Connection faild via cURL request.");
     }
     Hook::event("HttpRequestInitFirst", array($this));
     @curl_setopt($this->resource, CURLOPT_RETURNTRANSFER, true);
     @curl_setopt($this->resource, CURLOPT_TIMEOUT, self::TIMEOUT);
     $url = $this->webpage;
     if (count($this->getGetArgs()) > 0) {
         $url .= "?" . $this->getGetArgs(false);
     }
     @curl_setopt($this->resource, CURLOPT_URL, $url);
     if ($this->getRequestType() == "GET") {
         @curl_setopt($this->resource, CURLOPT_HTTPGET, true);
     } else {
         if ($this->getRequestType() == "POST") {
             @curl_setopt($this->resource, CURLOPT_POST, true);
             @curl_setopt($this->resource, CURLOPT_POSTFIELDS, $this->getPostArgs(false));
         } else {
             if ($this->getRequestType() == "PUT") {
                 @curl_setopt($this->resource, CURLOPT_PUT, true);
             }
         }
     }
     $this->response = curl_exec($this->resource);
     $this->errorNo = curl_errno($this->resource);
     if ($this->errorNo) {
         $this->error = curl_error($this->resource);
         throw new Recipe_Exception_Generic("There is an error occured in cURL session (" . $this->errorNo . "): " . $this->error);
     }
     Hook::event("HttpRequestInitLast", array($this));
     return $this;
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->productSort();
     // Override default configuration values: cause the new products page must display latest products first.
     if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
         $this->orderBy = 'date_add';
         $this->orderWay = 'DESC';
     }
     $nbProducts = (int) Product::getNewProducts($this->context->language->id, null, null, true);
     $this->pagination($nbProducts);
     $products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay);
     $this->addColorsToProductList($products);
     $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     if ($this->ajax) {
         $product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
         $pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl');
         $nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products));
         $nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100;
         echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage));
         die;
     } else {
         $this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
     }
 }
Beispiel #16
0
 public function index()
 {
     $this->load->model('admin/admin_menu');
     $this->load->add_package_path(APPPATH . 'third_party/scrud/');
     $_GET['table'] = 'crud_languages';
     $var = array();
     $conf = array();
     $var['main_menu'] = $this->admin_menu->fetch('tool');
     if (!file_exists(__DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/' . $_GET['table'] . '.php')) {
         exit;
     } else {
         require __DATABASE_CONFIG_PATH__ . '/' . $this->db->database . '/' . $_GET['table'] . '.php';
     }
     $hook = Hook::singleton();
     $hook->addFunction('SCRUD_EDIT_FORM', 'edit_form');
     $hook->addFunction('SCRUD_VALIDATE', 'validate_language_code');
     $hook->addFunction('SCRUD_BEFORE_UPDATE', 'before_update');
     $hook->addFunction('SCRUD_COMPLETE_SAVE', 'complete_save');
     $hook->addFunction('SCRUD_COMPLETE_DELETE', 'complete_delete');
     $conf['theme_path'] = FCPATH . 'application/views/admin/language/templates';
     $this->load->library('crud', array('table' => $_GET['table'], 'conf' => $conf));
     $var['main_content'] = $this->load->view('admin/language/index', array('content' => $this->crud->process()), true);
     $this->load->model('admin/admin_footer');
     $var['main_footer'] = $this->admin_footer->fetch();
     $this->load->view('layouts/admin/user/default', $var);
 }
 public function getPaymentOptions()
 {
     // Payment options coming from intermediate, deprecated version of the Advanced API
     $rawDisplayPaymentEUOptions = Hook::exec('displayPaymentEU', array(), null, true);
     if (!is_array($rawDisplayPaymentEUOptions)) {
         $rawDisplayPaymentEUOptions = array();
     }
     $displayPaymentEUOptions = array_map(array('PrestaShop\\PrestaShop\\Core\\Payment\\PaymentOption', 'convertLegacyOption'), $rawDisplayPaymentEUOptions);
     // Payment options coming from regular Advanced API
     $advancedPaymentOptions = Hook::exec('advancedPaymentOptions', array(), null, true);
     if (!is_array($advancedPaymentOptions)) {
         $advancedPaymentOptions = array();
     }
     // Payment options coming from regular Advanced API
     $newOption = Hook::exec('paymentOptions', array(), null, true);
     if (!is_array($newOption)) {
         $newOption = array();
     }
     $paymentOptions = array_merge($displayPaymentEUOptions, $advancedPaymentOptions, $newOption);
     foreach ($paymentOptions as $paymentOptionKey => $paymentOption) {
         if (!is_array($paymentOption)) {
             unset($paymentOptions[$paymentOptionKey]);
         }
     }
     return $paymentOptions;
 }
 /**
  * Ajax方式返回数据到客户端
  * @access protected
  * @param mixed $data 要返回的数据
  * @param String $type AJAX返回数据格式
  * @return void
  */
 protected function ajaxReturn($data, $type = '', $json_option = 0)
 {
     $data['referer'] = $data['url'] ? $data['url'] : "";
     $data['state'] = $data['status'] ? "success" : "fail";
     if (empty($type)) {
         $type = C('DEFAULT_AJAX_RETURN');
     }
     switch (strtoupper($type)) {
         case 'JSON':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:application/json; charset=utf-8');
             exit(json_encode($data, $json_option));
         case 'XML':
             // 返回xml格式数据
             header('Content-Type:text/xml; charset=utf-8');
             exit(xml_encode($data));
         case 'JSONP':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:application/json; charset=utf-8');
             $handler = isset($_GET[C('VAR_JSONP_HANDLER')]) ? $_GET[C('VAR_JSONP_HANDLER')] : C('DEFAULT_JSONP_HANDLER');
             exit($handler . '(' . json_encode($data, $json_option) . ');');
         case 'EVAL':
             // 返回可执行的js脚本
             header('Content-Type:text/html; charset=utf-8');
             exit($data);
         case 'AJAX_UPLOAD':
             // 返回JSON数据格式到客户端 包含状态信息
             header('Content-Type:text/html; charset=utf-8');
             exit(json_encode($data, $json_option));
         default:
             // 用于扩展其他返回格式数据
             Hook::listen('ajax_return', $data);
     }
 }
Beispiel #19
0
 public function text()
 {
     $text = nl2br($this->entity->text);
     //turn links to clickable
     $text = app('App\\Repositories\\PostRepository')->turnLinks($text);
     return \Hook::fire('post-text', $text);
 }
Beispiel #20
0
 public static function instance()
 {
     if (self::$instance === NULL) {
         self::$instance = new Hook();
     }
     return self::$instance;
 }
Beispiel #21
0
 /**
  * 发送数据到客户端
  * @access protected
  * @param mixed $data 要返回的数据
  * @param String $type 返回数据格式
  * @param bool $return 是否返回数据
  * @return void
  */
 public static function send($data = '', $type = '', $return = false)
 {
     $type = strtolower($type ?: self::$type);
     $headers = ['json' => 'application/json', 'xml' => 'text/xml', 'html' => 'text/html', 'jsonp' => 'application/javascript', 'script' => 'application/javascript', 'text' => 'text/plain'];
     if (!headers_sent() && isset($headers[$type])) {
         header('Content-Type:' . $headers[$type] . '; charset=utf-8');
     }
     $data = $data ?: self::$data;
     if (is_callable(self::$tramsform)) {
         $data = call_user_func_array(self::$tramsform, [$data]);
     } else {
         switch ($type) {
             case 'json':
                 // 返回JSON数据格式到客户端 包含状态信息
                 $data = json_encode($data, JSON_UNESCAPED_UNICODE);
                 break;
             case 'jsonp':
                 // 返回JSON数据格式到客户端 包含状态信息
                 $handler = !empty($_GET[Config::get('var_jsonp_handler')]) ? $_GET[Config::get('var_jsonp_handler')] : Config::get('default_jsonp_handler');
                 $data = $handler . '(' . json_encode($data, JSON_UNESCAPED_UNICODE) . ');';
                 break;
             case '':
                 // 类型为空不做处理
                 break;
             default:
                 // 用于扩展其他返回格式数据
                 APP_HOOK && Hook::listen('return_data', $data);
         }
     }
     if ($return) {
         return $data;
     }
     echo $data;
     self::isExit() && exit;
 }
Beispiel #22
0
 /**
  * Logs the current user out
  * 
  * @return void
  */
 public static function logout()
 {
     // trigger a hook
     Hook::run('auth', 'logout', 'call', null, Auth::getCurrentMember());
     $app = \Slim\Slim::getInstance();
     $app->deleteCookie('stat_auth_cookie');
 }
 public function display()
 {
     $order_invoice_list = $this->order->getInvoicesCollection();
     Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list));
     $pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty);
     $pdf->render();
 }
 public function initContent()
 {
     parent::initContent();
     if ($id_category = Tools::getvalue('id_category') && Tools::getvalue('id_category') != Null) {
         $this->context->smarty->assign(BlogCategory::GetMetaByCategory(Tools::getvalue('id_category')));
     }
     if ($id_post = Tools::getvalue('id_post') && Tools::getvalue('id_post') != Null) {
         $this->context->smarty->assign(SmartBlogPost::GetPostMetaByPost(Tools::getvalue('id_post')));
     }
     if (Tools::getvalue('id_category') == Null && Tools::getvalue('id_post') == Null) {
         $meta['meta_title'] = Configuration::get('smartblogmetatitle');
         $meta['meta_description'] = Configuration::get('smartblogmetadescrip');
         $meta['meta_keywords'] = Configuration::get('smartblogmetakeyword');
         $this->context->smarty->assign($meta);
     }
     if (Configuration::get('smartshowcolumn') == 0) {
         $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight')));
     } elseif (Configuration::get('smartshowcolumn') == 1) {
         $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft')));
     } elseif (Configuration::get('smartshowcolumn') == 2) {
         $this->context->smarty->assign(array('HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight')));
     } elseif (Configuration::get('smartshowcolumn') == 3) {
         $this->context->smarty->assign(array());
     } else {
         $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displaySmartBlogLeft'), 'HOOK_RIGHT_COLUMN' => Hook::exec('displaySmartBlogRight')));
     }
 }
Beispiel #25
0
 protected function safe_offset($value)
 {
     if ($value instanceof \Closure) {
         $value = '__CLOSURE__';
     }
     return parent::safe_offset($value);
 }
Beispiel #26
0
 /**
  * Combat report action.
  *
  * @return Bengine_Comm_Controller_Combat
  */
 public function reportAction()
 {
     if (!defined("SID")) {
         define("SID", "");
     }
     Core::getLanguage()->load(array("info", "AssaultReport"));
     Core::getTPL()->clearHTMLHeaderFiles();
     Core::getTPL()->addHTMLHeaderFile("game.css", "css");
     Core::getTPL()->addHTMLHeaderFile("lib/jquery.js", "js");
     $select = new Recipe_Database_Select();
     $select->from(array("a" => "assault"))->join(array("p" => "planet"), "p.planetid = a.planetid")->attributes(array("a" => array("report"), "p" => array("planetname")))->where(array("a" => "assaultid"), $this->getParam("1"))->where(array("a" => "key"), $this->getParam("2"));
     $result = $select->getStatement();
     $row = $result->fetchRow();
     if ($row) {
         $report = $row["report"];
         $report = preg_replace_callback("/\\{lang}([^\"]+)\\{\\/lang}/siU", function ($matches) {
             return Core::getLanguage()->getItem($matches[1]);
         }, $report);
         $report = preg_replace_callback("/\\{embedded\\[([^\"]+)]}(.*)\\{\\/embedded}/siU", function ($matches) {
             return sprintf(Core::getLanguage()->getItem($matches[1]), $matches[2]);
         }, $report);
         Hook::event("ShowCombatReport", array(&$report, &$row));
         $this->assign("report", $report);
         $this->assign("planetName", $row["planetname"]);
         $this->setIsAjax();
     } else {
         $this->setNoDisplay(true);
     }
     return $this;
 }
 function process_login()
 {
     $username = addslashes($_POST["admin_email"]);
     $password = addslashes($_POST["admin_password"]);
     $rememberme = isset($_POST["rememberme"]) ? 1 : 0;
     if ($password == "") {
         $password = "******";
     }
     $row = array("admin_email" => $username, "admin_password" => $password, "rememberme" => $rememberme);
     /*if ($this->ldapLogin($username, $password)) {
     			$row["admin_ldap"] = 1;
     		}*/
     //login pakai row credential
     Auth::login($row);
     //kalau sukses
     if (Auth::isLogged()) {
         //load school setting
         // $ss = new Schoolsetting();
         // $ss->loadToSession();
         //redirect
         //Account::setRedirection ();
         Hook::processHook($this->login_hook);
         Redirect::firstPage();
     } else {
         Redirect::loginFailed();
     }
 }
Beispiel #28
0
 /**
  * Alliance page action.
  *
  * @return Bengine_Comm_Controller_Alliance
  */
 public function pageAction()
 {
     Core::getLanguage()->load("Alliance");
     Core::getTPL()->clearHTMLHeaderFiles();
     Core::getTPL()->addHTMLHeaderFile("game.css", "css");
     Core::getTPL()->addHTMLHeaderFile("lib/jquery.js", "js");
     $tag = $this->getParam("1");
     $fNumber = array("member", "points", "rpoints", "fpoints", "dpoints");
     $attr = array("a.aid", "a.name", "a.tag", "a.logo", "a.textextern", "a.homepage", "a.showhomepage", "COUNT(u2a.userid) AS member", "SUM(u.points) AS points", "SUM(u.rpoints) AS rpoints", "SUM(u.fpoints) AS fpoints", "SUM(u.dpoints) AS dpoints");
     $joins = "LEFT JOIN " . PREFIX . "user2ally u2a ON (u2a.aid = a.aid) ";
     $joins .= "LEFT JOIN " . PREFIX . "user u ON (u2a.userid = u.userid) ";
     $result = Core::getQuery()->select("alliance a", $attr, $joins, Core::getDB()->quoteInto("tag = ?", $tag), "", 1, "a.aid");
     $row = $result->fetchRow();
     if ($row) {
         foreach ($fNumber as $field) {
             $row[$field] = fNumber($row[$field]);
         }
         $parser = new Bengine_Game_Alliance_Page_Parser($row["aid"]);
         if (Str::length(strip_tags($row["textextern"])) > 0) {
             $row["textextern"] = $parser->startParser($row["textextern"]);
         } else {
             $row["textextern"] = Core::getLang()->get("WELCOME");
         }
         $row["homepage"] = $row["homepage"] != "" ? Link::get($row["homepage"], $row["homepage"], $row["homepage"]) : "";
         $row["logo"] = $row["logo"] != "" ? Image::getImage($row["logo"], "") : "";
         Hook::event("ShowPublicAlliancePage", array(&$row));
         $this->assign($row);
         $this->setIsAjax();
     } else {
         $this->setNoDisplay(true);
     }
     return $this;
 }
Beispiel #29
0
 private function _checkValues()
 {
     $errors = array();
     if (isset($_POST['submitPaypalSettings'])) {
         if (!isset($_POST['sandbox'])) {
             $_POST['sandbox'] = 1;
         }
         if (!isset($_POST['expressCheckout'])) {
             $_POST['expressCheckout'] = 0;
         }
         if (!$this->_expressCheckout and intval($_POST['expressCheckout'])) {
             if (!$this->registerHook('shoppingCartExtra')) {
                 $errors[] = $this->l('Cannot register module to validCart hook, ExpressCheckout not enabled');
                 $_POST['expressCheckout'] = 0;
             }
         }
         if ($this->_expressCheckout and !intval($_POST['expressCheckout'])) {
             if (!$this->unregisterHook(Hook::get('shoppingCartExtra'))) {
                 $errors[] = $this->l('Cannot unregister module to validCart hook, ExpressCheckout not disabled');
                 $_POST['expressCheckout'] = 1;
             }
         }
     } elseif (isset($_POST['submitPaypalAPI'])) {
         if (!isset($_POST['apiUser']) or !$_POST['apiUser']) {
             $errors[] = $this->l('You need to configure your PayPal API username');
         }
         if (!isset($_POST['apiPassword']) or !$_POST['apiPassword']) {
             $errors[] = $this->l('You need to configure your PayPal API password');
         }
         if (!isset($_POST['apiSignature']) or !$_POST['apiSignature']) {
             $errors[] = $this->l('You need to configure your PayPal API signature');
         }
     }
     return $errors;
 }
Beispiel #30
0
/**
 * Render user box
 *
 * @param User $user
 * @return null
 */
function render_user_box(Contact $user) {
	tpl_assign('_userbox_user', $user);
	$crumbs = array(); 
	$crumbs[] = array(
		'url' => get_url('help','help_options', array('current' => 'help')),
		'text' => lang('help'),
	);
	$crumbs[] = array(
		'url' => logged_user()->getAccountUrl(), 
		'target' => 'account',
		'text' => lang('account'),
	);
	
	if (logged_user()->isExecutiveGroup()) {
		$crumbs[] = array(
			'url' => get_url('administration', 'index'),
			'target' => 'administration',
			'text' => lang('administration'),
		);
	}
	
	Hook::fire('render_userbox_crumbs', null, $crumbs);
	$crumbs = array_reverse($crumbs);
	tpl_assign('_userbox_crumbs', $crumbs);
	return tpl_fetch(get_template_path('user_box', 'application'));
} // render_user_box