Ejemplo n.º 1
0
 static function cloneProfile(Profile $prof)
 {
     $plugprof = new self();
     if ($plugprof->getFromDB($prof->input['_old_id'])) {
         $input = ToolBox::addslashes_deep($plugprof->fields);
         $input['id'] = $prof->getID();
         $plugprof->add($input);
     }
 }
Ejemplo n.º 2
0
 /**
  * if profile cloned
  *
  * @param $prof   Profile  object
  **/
 static function cloneProfile(Profile $prof)
 {
     global $DB;
     $plugprof = new self();
     $crit = array('profiles_id' => $prof->input['_old_id']);
     foreach ($DB->request($plugprof->getTable(), $crit) as $data) {
         $input = ToolBox::addslashes_deep($data);
         unset($input['id']);
         $input['profiles_id'] = $prof->getID();
         $plugprof->add($input);
     }
 }
Ejemplo n.º 3
0
    public function installDB()
    {
        // Creation of the tables in a database
        $result = true;
        $queries = array();
        $queries[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'orders_gateway_order_state` (
			`id_order_gateway_order_state` INT UNSIGNED NOT NULL AUTO_INCREMENT,
			`id_order` INT UNSIGNED NOT NULL,
			`id_order_state` INT UNSIGNED NOT NULL,
			`date_add` DATETIME NOT NULL,
			`date_upd` DATETIME NOT NULL,
			PRIMARY KEY (`id_order_gateway_order_state`)
		) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';
        $queries[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'orders_gateway` (
			`id_order_gateway` INT UNSIGNED NOT NULL AUTO_INCREMENT,
			`id_order_neteven` INT UNSIGNED NOT NULL,
			`id_order_detail_neteven` INT UNSIGNED NOT NULL,
			`id_order` INT UNSIGNED NOT NULL,
			`date_add` DATETIME NOT NULL,
			`date_upd` DATETIME NOT NULL,
			PRIMARY KEY (`id_order_gateway`)
		) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';
        $queries[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'orders_gateway_customer` (
			`id_order_gateway_customer` INT UNSIGNED NOT NULL AUTO_INCREMENT,
			`id_customer_neteven` INT UNSIGNED,
			`id_customer` INT UNSIGNED NOT NULL,
			`mail_customer_neteven` VARCHAR(255),
			`date_add` DATETIME NOT NULL,
			PRIMARY KEY (`id_order_gateway_customer`)
		) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';
        $queries[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'orders_gateway_configuration` (
			`id_order_gateway_configuration` INT UNSIGNED NOT NULL AUTO_INCREMENT,
			`name` VARCHAR(255),
			`value` VARCHAR(255),
			PRIMARY KEY (`id_order_gateway_configuration`),
			KEY `name` (`name`)
		) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';
        $queries[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'orders_gateway_feature_link` (
			`id_order_gateway_feature_link` INT UNSIGNED NOT NULL AUTO_INCREMENT,
			`id_order_gateway_feature` INT UNSIGNED NOT NULL,
			`id_feature` INT UNSIGNED,
			`id_attribute_group` INT UNSIGNED,
			PRIMARY KEY (`id_order_gateway_feature_link`)
		) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';
        $queries[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'orders_gateway_feature` (
			`id_order_gateway_feature` INT UNSIGNED NOT NULL AUTO_INCREMENT,
			`name` VARCHAR(255),
			`value` VARCHAR(255),
			`category` VARCHAR(255),
			PRIMARY KEY (`id_order_gateway_feature`)
		) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;';
        foreach ($queries as $query) {
            $result &= Db::getInstance()->Execute($query);
        }
        if (!$result) {
            return false;
        }
        // Update table `orders_gateway_feature`
        ToolBox::setNetEvenCategories();
        return true;
    }
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../../config/config.inc.php';
include_once dirname(__FILE__) . '/../classes/Toolbox.php';
if (Tools::getValue('token') != Tools::encrypt(Configuration::get('PS_SHOP_NAME'))) {
    die(Tools::displayError());
}
ToolBox::setNetEvenCategories(true);
die;
Ejemplo n.º 5
0
 static function cloneItem(array $param)
 {
     // Sanity check
     if (!isset($param['itemtype']) || !isset($param['id']) || !isset($param['name']) || !array_key_exists($param['itemtype'], self::$clone_types) || empty($param['name']) || !($item = getItemForItemtype($param['itemtype']))) {
         return false;
     }
     // Read original and prepare clone
     $item->check($param['id'], 'r');
     $input = ToolBox::addslashes_deep($item->fields);
     $input['name'] = $param['name'];
     $input['_add'] = 1;
     $input['_old_id'] = $input['id'];
     unset($input['id']);
     if ($item->isEntityAssign()) {
         $input['entities_id'] = $_SESSION['glpiactive_entity'];
     }
     // Manage NULL fields in original
     foreach ($input as $k => $v) {
         if (is_null($input[$k])) {
             $input[$k] = "NULL";
         }
     }
     // Specific to itemtype - before clone
     if (method_exists(self::$clone_types[$param['itemtype']], 'preClone')) {
         $input = call_user_func(array(self::$clone_types[$param['itemtype']], 'preClone'), $item, $input);
     }
     // Clone
     $clone = clone $item;
     $clone->check(-1, 'w', $input);
     $new = $clone->add($input);
     // Specific to itemtype - after clone
     if (method_exists(self::$clone_types[$param['itemtype']], 'postClone')) {
         call_user_func(array(self::$clone_types[$param['itemtype']], 'postClone'), $clone, $param['id']);
     }
     Plugin::doHook('item_clone', $clone);
     // History
     if ($clone->dohistory) {
         $changes[0] = '0';
         $changes[1] = '';
         $changes[2] = addslashes(sprintf(__('%1$s %2$s'), __('Clone of', 'behaviors'), $item->getNameID(0, true)));
         Log::history($clone->getID(), $clone->getType(), $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
     }
 }
/*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/../../../config/config.inc.php';
include_once dirname(__FILE__) . '/../classes/Toolbox.php';
if (Tools::getValue('token') != Tools::encrypt(Configuration::get('PS_SHOP_NAME'))) {
    die(Tools::displayError());
}
ToolBox::setNetEvenCategories();
Ejemplo n.º 7
0
 /**
  * Returns a hashmap with bean arrays keyed by type using an SQL
  * query as its resource. Given an SQL query like 'SELECT movie.*, review.* FROM movie... JOIN review'
  * this method will return movie and review beans.
  *
  * Example:
  *
  * <code>
  * $stuff = $finder->findMulti('movie,review', '
  *          SELECT movie.*, review.* FROM movie
  *          LEFT JOIN review ON review.movie_id = movie.id');
  * </code>
  *
  * After this operation, $stuff will contain an entry 'movie' containing all
  * movies and an entry named 'review' containing all reviews (all beans).
  * You can also pass bindings.
  *
  * If you want to re-map your beans, so you can use $movie->ownReviewList without
  * having RedBeanPHP executing an SQL query you can use the fourth parameter to
  * define a selection of remapping closures.
  *
  * The remapping argument (optional) should contain an array of arrays.
  * Each array in the remapping array should contain the following entries:
  *
  * <code>
  * array(
  * 	'a'       => TYPE A
  *    'b'       => TYPE B
  *    'matcher' => MATCHING FUNCTION ACCEPTING A, B and ALL BEANS
  *    'do'      => OPERATION FUNCTION ACCEPTING A, B, ALL BEANS, ALL REMAPPINGS
  * )
  * </code>
  *
  * Using this mechanism you can build your own 'preloader' with tiny function
  * snippets (and those can be re-used and shared online of course).
  *
  * Example:
  *
  * <code>
  * array(
  * 	'a'       => 'movie'     //define A as movie
  *    'b'       => 'review'    //define B as review
  *    'matcher' => function( $a, $b ) {
  *       return ( $b->movie_id == $a->id );  //Perform action if review.movie_id equals movie.id
  *    }
  *    'do'      => function( $a, $b ) {
  *       $a->noLoad()->ownReviewList[] = $b; //Add the review to the movie
  *       $a->clearHistory();                 //optional, act 'as if these beans have been loaded through ownReviewList'.
  *    }
  * )
  * </code>
  *
  * The Query Template parameter is optional as well but can be used to
  * set a different SQL template (sprintf-style) for processing the original query.
  *
  * @note the SQL query provided IS NOT THE ONE used internally by this function,
  * this function will pre-process the query to get all the data required to find the beans.
  *
  * @note if you use the 'book.*' notation make SURE you're
  * selector starts with a SPACE. ' book.*' NOT ',book.*'. This is because
  * it's actually an SQL-like template SLOT, not real SQL.
  *
  * @note instead of an SQL query you can pass a result array as well.
  *
  * @param string|array $types         a list of types (either array or comma separated string)
  * @param string|array $sqlOrArr      an SQL query or an array of prefetched records
  * @param array        $bindings      optional, bindings for SQL query
  * @param array        $remappings    optional, an array of remapping arrays
  * @param string       $queryTemplate optional, query template
  *
  * @return array
  */
 public function findMulti($types, $sql, $bindings = array(), $remappings = array(), $queryTemplate = ' %s.%s AS %s__%s')
 {
     if (!is_array($types)) {
         $types = explode(',', $types);
     }
     if (!is_array($sql)) {
         $writer = $this->toolbox->getWriter();
         $adapter = $this->toolbox->getDatabaseAdapter();
         //Repair the query, replace book.* with book.id AS book_id etc..
         foreach ($types as $type) {
             $pattern = " {$type}.*";
             if (strpos($sql, $pattern) !== FALSE) {
                 $newSelectorArray = array();
                 $columns = $writer->getColumns($type);
                 foreach ($columns as $column => $definition) {
                     $newSelectorArray[] = sprintf($queryTemplate, $type, $column, $type, $column);
                 }
                 $newSelector = implode(',', $newSelectorArray);
                 $sql = str_replace($pattern, $newSelector, $sql);
             }
         }
         $rows = $adapter->get($sql, $bindings);
     } else {
         $rows = $sql;
     }
     //Gather the bean data from the query results using the prefix
     $wannaBeans = array();
     foreach ($types as $type) {
         $wannaBeans[$type] = array();
         $prefix = "{$type}__";
         foreach ($rows as $rowkey => $row) {
             $wannaBean = array();
             foreach ($row as $cell => $value) {
                 if (strpos($cell, $prefix) === 0) {
                     $property = substr($cell, strlen($prefix));
                     unset($rows[$rowkey][$cell]);
                     $wannaBean[$property] = $value;
                 }
             }
             if (!isset($wannaBean['id'])) {
                 continue;
             }
             if (is_null($wannaBean['id'])) {
                 continue;
             }
             $wannaBeans[$type][$wannaBean['id']] = $wannaBean;
         }
     }
     //Turn the rows into beans
     $beans = array();
     foreach ($wannaBeans as $type => $wannabees) {
         $beans[$type] = $this->redbean->convertToBeans($type, $wannabees);
     }
     //Apply additional re-mappings
     foreach ($remappings as $remapping) {
         $a = $remapping['a'];
         $b = $remapping['b'];
         $matcher = $remapping['matcher'];
         $do = $remapping['do'];
         foreach ($beans[$a] as $bean) {
             foreach ($beans[$b] as $putBean) {
                 if ($matcher($bean, $putBean, $beans)) {
                     $do($bean, $putBean, $beans, $remapping);
                 }
             }
         }
     }
     return $beans;
 }