/**
  * Register some observers to update mechanic values.
  */
 public function onAfterInitialise()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     if ($app->isAdmin()) {
         return;
     }
     $document = JFactory::getDocument();
     /** @var $document JDocumentHTML */
     $type = $document->getType();
     if (strcmp("html", $type) != 0) {
         return;
     }
     // Register Observers
     // Register observer for leveling when system increase points value.
     if ($this->params->get("enable_leveling", 0)) {
         $options = array('typeAlias' => 'com_gamification.leveling', 'send_notification' => $this->params->get("leveling_send_notification", 0), 'store_activity' => $this->params->get("leveling_store_activity", 0));
         JObserverMapper::addObserverClassToClass('Gamification\\Observer\\User\\Leveling', 'Gamification\\User\\Points', $options);
     }
     if ($this->params->get("enable_badging", 0)) {
         $options = array('typeAlias' => 'com_gamification.badging', 'send_notification' => $this->params->get("badging_send_notification", 0), 'store_activity' => $this->params->get("badging_store_activity", 0));
         JObserverMapper::addObserverClassToClass('Gamification\\Observer\\User\\Badging', 'Gamification\\User\\Points', $options);
     }
     if ($this->params->get("enable_ranking", 0)) {
         $options = array('typeAlias' => 'com_gamification.ranking', 'send_notification' => $this->params->get("ranking_send_notification", 0), 'store_activity' => $this->params->get("ranking_store_activity", 0));
         JObserverMapper::addObserverClassToClass('Gamification\\Observer\\User\\Ranking', 'Gamification\\User\\Points', $options);
     }
 }
Пример #2
0
 public function __construct(&$db = null)
 {
     parent::__construct('#__dpfields_fields', 'id', $db);
     $this->setColumnAlias('published', 'state');
     JObserverMapper::addObserverClassToClass('JTableObserverTags', 'DPFieldsTableField', array('typeAlias' => 'com_dpfields.field'));
     JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'DPFieldsTableField', array('typeAlias' => 'com_dpfields.field'));
 }
Пример #3
0
 /**
  * Constructor
  *
  * @param   JDatabase  &$db  A database connector object
  */
 public function __construct(&$db)
 {
     // add observer for content history
     JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'AkrecipesTablerecipe', array('typeAlias' => 'com_akrecipes.recipe'));
     parent::__construct('#__akrecipes_recipe', 'id', $db);
     // add observer for tags
     JTableObserverTags::createObserver($this, array('typeAlias' => 'com_akrecipes.recipe'));
 }
Пример #4
0
 /**
  * Initialize the object.
  *
  * @param \JDatabaseDriver $db
  */
 public function __construct(\JDatabaseDriver $db = null)
 {
     $this->db = $db;
     // Implement JObservableInterface:
     // Create observer updater and attaches all observers interested by $this class:
     $this->observers = new \JObserverUpdater($this);
     \JObserverMapper::attachAllObservers($this);
 }
 /**
  * Constructor.
  *
  * @param   string                    $table  Table name.
  * @param   string|array              $pk     Primary key.
  * @param   DatabaseAdapterInterface  $db     Database adapter.
  */
 public function __construct($table = null, $pk = 'id', DatabaseAdapterInterface $db = null)
 {
     // Implement JObservableInterface:
     // Create observer updater and attaches all observers interested by $this class:
     $this->observers = new \JObserverUpdater($this);
     \JObserverMapper::attachAllObservers($this);
     parent::__construct($table, $pk, $db);
     $this->relation = new Relation(new Table($this->table, $this->pk, $this->db->getDb()));
     $this->attachObserver(new RelationObserver($this));
     $this->observers->update('onAfterConstruction', array());
 }
Пример #6
0
 /**
  * Constructor
  *
  * @param JDatabase A database connector object
  */
 public function __construct(&$db)
 {
     // Set Observer
     if (version_compare(JVERSION, '3.1.4', '<')) {
         $this->_observers = new JObserverUpdater($this);
         JObserverMapper::attachAllObservers($this);
     }
     // Attach Tags Observer
     JObserverMapper::addObserverClassToClass('JTableObserverTags', 'WebgalleryTableItem', array('typeAlias' => 'com_webgallery.item'));
     parent::__construct('#__webgallery_items', 'id', $db);
 }
Пример #7
0
 public function __construct($table, $key, $db)
 {
     // Set internal variables.
     $this->_tbl = $table;
     $this->_tbl_key = $key;
     // For Joomla 3.2 onwards
     $this->_tbl_keys = array($key);
     $this->_db = $db;
     // Implement JObservableInterface:
     // Create observer updater and attaches all observers interested by $this class:
     $version = EB::getJoomlaVersion();
     if ($version >= '3.0' && class_exists('JObserverUpdater')) {
         $this->_observers = new JObserverUpdater($this);
         JObserverMapper::attachAllObservers($this);
     }
 }
Пример #8
0
JLoader::register('JToolBar', JPATH_PLATFORM . '/cms/toolbar/toolbar.php');
JLoader::register('JButton', JPATH_PLATFORM . '/cms/toolbar/button.php');
JLoader::register('JInstallerComponent', JPATH_PLATFORM . '/cms/installer/adapter/component.php');
JLoader::register('JInstallerFile', JPATH_PLATFORM . '/cms/installer/adapter/file.php');
JLoader::register('JInstallerLanguage', JPATH_PLATFORM . '/cms/installer/adapter/language.php');
JLoader::register('JInstallerLibrary', JPATH_PLATFORM . '/cms/installer/adapter/library.php');
JLoader::register('JInstallerModule', JPATH_PLATFORM . '/cms/installer/adapter/module.php');
JLoader::register('JInstallerPackage', JPATH_PLATFORM . '/cms/installer/adapter/package.php');
JLoader::register('JInstallerPlugin', JPATH_PLATFORM . '/cms/installer/adapter/plugin.php');
JLoader::register('JInstallerTemplate', JPATH_PLATFORM . '/cms/installer/adapter/template.php');
JLoader::register('JExtension', JPATH_PLATFORM . '/cms/installer/extension.php');
JLoader::registerAlias('JAdministrator', 'JApplicationAdministrator');
JLoader::registerAlias('JSite', 'JApplicationSite');
// Register Observers:
// Add Tags to Content, Contact, NewsFeeds, WebLinks and Categories: (this is the only link between them here!):
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'JTableContent', array('typeAlias' => 'com_content.article'));
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'ContactTableContact', array('typeAlias' => 'com_contact.contact'));
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'NewsfeedsTableNewsfeed', array('typeAlias' => 'com_newsfeeds.newsfeed'));
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'WeblinksTableWeblink', array('typeAlias' => 'com_weblinks.weblink'));
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'JTableCategory', array('typeAlias' => '{extension}.category'));
// Register Observers for Version History
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'ContactTableContact', array('typeAlias' => 'com_contact.contact'));
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'JTableContent', array('typeAlias' => 'com_content.article'));
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'JTableCategory', array('typeAlias' => '{extension}.category'));
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'NewsfeedsTableNewsfeed', array('typeAlias' => 'com_newsfeeds.newsfeed'));
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'WeblinksTableWeblink', array('typeAlias' => 'com_weblinks.weblink'));
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'BannersTableBanner', array('typeAlias' => 'com_banners.banner'));
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'BannersTableClient', array('typeAlias' => 'com_banners.client'));
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'TagsTableTag', array('typeAlias' => 'com_tags.tag'));
JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'UsersTableNote', array('typeAlias' => 'com_users.note'));
Пример #9
0
 function getImportInfo()
 {
     $this->onExecuteBefore('getImportInfo');
     $encoding = $this->getState('encoding');
     if ($encoding == 'cp1251') {
         setLocale(LC_ALL, 'ru_RU.CP1251');
     }
     if ($_FILES['photos_zip']['tmp_name'] != '') {
         $import_dir = JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'import' . DS;
         JFolder::delete($import_dir);
         JFolder::create($import_dir, 0777);
         copy($_FILES['photos_zip']['tmp_name'], $import_dir . 'import.zip');
         $result = JArchive::extract(JPath::clean($import_dir . 'import.zip'), JPath::clean($import_dir));
     }
     $unic = JRequest::getVar('unic');
     $f = fopen(JPATH_COMPONENT . DS . 'tmp' . DS . 'import.csv', "rt") or die("Ошибка!");
     $info = array('insert' => '', 'update' => '');
     $relatives = array();
     for ($k = 0; $data = fgetcsv($f, 10000, ";"); $k++) {
         if ($k == 0) {
             $headers = $data;
             continue;
         }
         $product_data = array();
         if ($k > 0) {
             if (isset($_POST['title']) && $_POST['title'] != '') {
                 $product_data['title'] = $this->encode($data[$_POST['title']]);
             }
             if (isset($_POST['parent_id']) && $_POST['parent_id'] != '') {
                 $product_data['parent_id'] = $this->encode($data[$_POST['parent_id']]);
             }
             if (isset($_POST['categories']) && $_POST['categories'] != '') {
                 $product_data['categories'] = $this->encode($data[$_POST['categories']]);
             }
             if (isset($_POST['childs_group']) && $_POST['childs_group'] != '') {
                 $product_data['childs_group'] = $this->encode($data[$_POST['childs_group']]);
             }
             if (isset($_POST['price']) && $_POST['price'] != '') {
                 $product_data['price'] = str_replace(' ', '', $this->encode($data[$_POST['price']]));
             }
             if (isset($_POST['promotion_price']) && $_POST['promotion_price'] != '') {
                 $product_data['promotion_price'] = (double) str_replace(' ', '', $this->encode($data[$_POST['promotion_price']]));
             }
             if (isset($_POST['price_type']) && $_POST['price_type'] != '') {
                 $product_data['price_type'] = str_replace(' ', '', $this->encode($data[$_POST['price_type']]));
             }
             if (isset($_POST['product_code']) && $_POST['product_code'] != '') {
                 $product_data['product_code'] = $this->encode($data[$_POST['product_code']]);
             }
             if (isset($_POST['product_packaging']) && $_POST['product_packaging'] != '') {
                 $product_data['product_packaging'] = (double) str_replace(' ', '', $this->encode($data[$_POST['product_packaging']]));
             }
             if (isset($_POST['product_unit']) && $_POST['product_unit'] != '') {
                 $product_data['product_unit'] = str_replace(' ', '', $this->encode($data[$_POST['product_unit']]));
             }
             if (isset($_POST['in_stock']) && $_POST['in_stock'] != '') {
                 $product_data['in_stock'] = (double) $this->encode($data[$_POST['in_stock']]);
             }
             if (isset($_POST['promotion']) && $_POST['promotion'] != '') {
                 $product_data['promotion'] = $this->encode($data[$_POST['promotion']]);
             }
             if (isset($_POST['manufacturer']) && $_POST['manufacturer'] != '') {
                 $product_data['manufacturer'] = $this->encode($data[$_POST['manufacturer']]);
             }
             if (isset($_POST['country']) && $_POST['country'] != '') {
                 $product_data['country'] = $this->encode($data[$_POST['country']]);
             }
             if (isset($_POST['content']) && $_POST['content'] != '') {
                 $product_data['content'] = $this->encode($data[$_POST['content']]);
             }
             if (isset($_POST['photos']) && $_POST['photos'] != '') {
                 $product_data['photos'] = $this->encode($data[$_POST['photos']]);
             }
             if (isset($_POST['relative']) && $_POST['relative'] != '') {
                 $product_data['relative'] = $this->encode($data[$_POST['relative']]);
             }
             if (isset($_POST['tags']) && $_POST['tags'] != '') {
                 $product_data['tags'] = $this->encode($data[$_POST['tags']]);
             }
             if (isset($_POST['metatitle']) && $_POST['metatitle'] != '') {
                 $product_data['metatitle'] = $this->encode($data[$_POST['metatitle']]);
             } else {
                 $product_data['metatitle'] = '';
             }
             if (isset($_POST['metadescription']) && $_POST['metadescription'] != '') {
                 $product_data['metadescription'] = $this->encode($data[$_POST['metadescription']]);
             } else {
                 $product_data['metadescription'] = '';
             }
             if (isset($_POST['metakeywords']) && $_POST['metakeywords'] != '') {
                 $product_data['metakeywords'] = $this->encode($data[$_POST['metakeywords']]);
             } else {
                 $product_data['metakeywords'] = '';
             }
             $product_data['type'] = 'product';
             $query = $this->_db->getQuery(true);
             $query->select('*')->from('#__ksenmart_properties')->order('ordering');
             $this->_db->setQuery($query);
             $properties = $this->_db->loadObjectList();
             foreach ($properties as $property) {
                 if (isset($_POST['property_' . $property->id]) && $_POST['property_' . $property->id] != '') {
                     $product_data['property_' . $property->id] = $this->encode($data[$_POST['property_' . $property->id]]);
                 }
             }
             $query = $this->_db->getQuery(true);
             $query->select('id')->from('#__ksenmart_currencies')->where('`default`=1');
             $this->_db->setQuery($query);
             $def_price_type = $this->_db->loadResult();
             $query = $this->_db->getQuery(true);
             $query->select('id')->from('#__ksenmart_product_units');
             $this->_db->setQuery($query, 0, 1);
             $def_unit = $this->_db->loadResult();
             if (isset($product_data['parent_id']) && $product_data['parent_id'] != '') {
                 $query = $this->_db->getQuery(true);
                 $query->select('id')->from('#__ksenmart_products')->where($unic . '=' . $this->_db->quote($product_data['parent_id']))->where('parent_id=0');
                 $this->_db->setQuery($query);
                 $parent_id = $this->_db->loadResult();
                 if (empty($parent_id)) {
                     $product_data['parent_id'] = 0;
                 } else {
                     $product_data['type'] = 'child';
                     $product_data['parent_id'] = $parent_id;
                     $query = $this->_db->getQuery(true);
                     $query->update('#__ksenmart_products')->set('is_parent=1')->where('id=' . $parent_id);
                     $this->_db->setQuery($query);
                     $this->_db->query();
                 }
             } else {
                 $product_data['parent_id'] = 0;
             }
             if (isset($product_data['childs_group']) && $product_data['childs_group'] != '' && $product_data['parent_id'] != 0) {
                 $query = $this->_db->getQuery(true);
                 $query->select('*')->from('#__ksenmart_products_child_groups')->where('title like ' . $this->_db->quote($product_data['childs_group']))->where('product_id=' . $product_data['parent_id']);
                 $this->_db->setQuery($query);
                 $childs_group = $this->_db->loadObject();
                 if (count($childs_group) == 0) {
                     $qvalues = array($this->_db->quote($product_data['childs_group']), $product_data['parent_id']);
                     $query = $this->_db->getQuery(true);
                     $query->insert('#__ksenmart_products_child_groups')->columns('title,product_id')->values(implode(',', $qvalues));
                     $this->_db->setQuery($query);
                     $this->_db->query();
                     $childs_group_id = $this->_db->insertid();
                     $product_data['childs_group'] = $childs_group_id;
                 } else {
                     $product_data['childs_group'] = $childs_group->id;
                 }
             } else {
                 $product_data['childs_group'] = 0;
             }
             if (isset($product_data['price_type']) && $product_data['price_type'] != '') {
                 $query = $this->_db->getQuery(true);
                 $query->select('*')->from('#__ksenmart_currencies')->where('title=' . $this->_db->quote($product_data['price_type']));
                 $this->_db->setQuery($query);
                 $price_type = $this->_db->loadObject();
                 if (count($price_type) == 0) {
                     $product_data['price_type'] = $def_price_type;
                 } else {
                     $product_data['price_type'] = $price_type->id;
                 }
             } else {
                 $product_data['price_type'] = $def_price_type;
             }
             if (isset($product_data['product_unit']) && $product_data['product_unit'] != '') {
                 $query = $this->_db->getQuery(true);
                 $query->select('*')->from('#__ksenmart_product_units')->where('form1=' . $this->_db->quote($product_data['product_unit']));
                 $this->_db->setQuery($query);
                 $unit = $this->_db->loadObject();
                 if (count($unit) == 0) {
                     $qvalues = array($this->_db->quote($product_data['product_unit']), $this->_db->quote($product_data['product_unit']), $this->_db->quote($product_data['product_unit']));
                     $query = $this->_db->getQuery(true);
                     $query->insert('#__ksenmart_product_units')->columns('form1,form2,form5')->values(implode(',', $qvalues));
                     $this->_db->setQuery($query);
                     $this->_db->query();
                     $unit_id = $this->_db->insertid();
                     $product_data['product_unit'] = $unit_id;
                 } else {
                     $product_data['product_unit'] = $unit->id;
                 }
             } else {
                 $product_data['product_unit'] = $def_unit;
             }
             if (isset($product_data['promotion_price']) && $product_data['promotion_price'] != '') {
                 $product_data['promotion'] = 1;
                 $product_data['old_price'] = $product_data['price'];
                 $product_data['price'] = $product_data['promotion_price'];
             } else {
                 $product_data['promotion'] = 0;
                 $product_data['old_price'] = 0;
             }
             if (isset($product_data['country']) && $product_data['country'] != '') {
                 $query = $this->_db->getQuery(true);
                 $query->select('*')->from('#__ksenmart_countries')->where('title=' . $this->_db->quote($product_data['country']));
                 $this->_db->setQuery($query);
                 $country = $this->_db->loadObject();
                 if (count($country) == 0) {
                     $alias = KSFunctions::GenAlias($product_data['country']);
                     $qvalues = array($this->_db->quote($product_data['country']), $this->_db->quote($alias), 1, $this->_db->quote($product_data['country']));
                     $query = $this->_db->getQuery(true);
                     $query->insert('#__ksenmart_countries')->columns('title,alias,published,metatitle')->values(implode(',', $qvalues));
                     $this->_db->setQuery($query);
                     $this->_db->query();
                     $country_id = $this->_db->insertid();
                     $product_data['country'] = $country_id;
                 } else {
                     $product_data['country'] = $country->id;
                 }
             } else {
                 $product_data['country'] = 0;
             }
             if (isset($product_data['manufacturer']) && $product_data['manufacturer'] != '') {
                 $query = $this->_db->getQuery(true);
                 $query->select('*')->from('#__ksenmart_manufacturers')->where('title=' . $this->_db->quote($product_data['manufacturer']));
                 $this->_db->setQuery($query);
                 $manufacturer = $this->_db->loadObject();
                 if (count($manufacturer) == 0) {
                     $alias = KSFunctions::GenAlias($product_data['manufacturer']);
                     $qvalues = array($this->_db->quote($product_data['manufacturer']), $this->_db->quote($alias), $this->_db->quote($product_data['country']), 1, $this->_db->quote($product_data['manufacturer']));
                     $query = $this->_db->getQuery(true);
                     $query->insert('#__ksenmart_manufacturers')->columns('title,alias,country,published,metatitle')->values(implode(',', $qvalues));
                     $this->_db->setQuery($query);
                     $this->_db->query();
                     $manufacturer_id = $this->_db->insertid();
                     $product_data['manufacturer'] = $manufacturer_id;
                 } else {
                     $product_data['manufacturer'] = $manufacturer->id;
                 }
             } else {
                 $product_data['manufacturer'] = 0;
             }
             $categories = explode(';', $product_data['categories']);
             $prd_cats = array();
             foreach ($categories as $cats) {
                 $parent = 0;
                 $prd_cat = 0;
                 $cats = explode(':', $cats);
                 foreach ($cats as $cat) {
                     $cat = trim($cat);
                     if ($cat != '') {
                         $query = $this->_db->getQuery(true);
                         $query->select('*')->from('#__ksenmart_categories')->where('title=' . $this->_db->quote($cat))->where('parent_id=' . $parent);
                         $this->_db->setQuery($query);
                         $category = $this->_db->loadObject();
                         if (!$category) {
                             $alias = KSFunctions::GenAlias($cat);
                             $qvalues = array($this->_db->quote($cat), $this->_db->quote($alias), $parent, 1);
                             $query = $this->_db->getQuery(true);
                             $query->insert('#__ksenmart_categories')->columns('title,alias,parent_id,published')->values(implode(',', $qvalues));
                             $this->_db->setQuery($query);
                             $this->_db->query();
                             $prd_cat = $this->_db->insertid();
                             $parent = $prd_cat;
                         } else {
                             $prd_cat = $category->id;
                             $parent = $prd_cat;
                         }
                         $prd_cats[] = $prd_cat;
                     }
                 }
             }
             if ($product_data['parent_id'] != 0) {
                 $prd_cats = array();
                 $query = $this->_db->getQuery(true);
                 $query->select('*')->from('#__ksenmart_products_categories')->where('product_id=' . $product_data['parent_id']);
                 $this->_db->setQuery($query);
                 $cats = $this->_db->loadObjectList();
                 foreach ($cats as $cat) {
                     $prd_cats[] = $cat->category_id;
                 }
             }
             if (!isset($product_data['price'])) {
                 $product_data['price'] = 0;
             }
             if (!isset($product_data['product_code'])) {
                 $product_data['product_code'] = '';
             }
             if (!isset($product_data['product_packaging'])) {
                 $product_data['product_packaging'] = 1;
             }
             if (!isset($product_data['in_stock'])) {
                 $product_data['in_stock'] = 1;
             }
             if (!isset($product_data['content'])) {
                 $product_data['content'] = '';
             }
             if ($unic != '') {
                 $query = $this->_db->getQuery(true);
                 $query->select('*')->from('#__ksenmart_products')->where($unic . '=' . $this->_db->quote($product_data[$unic]))->where('parent_id=' . $product_data['parent_id']);
                 $this->_db->setQuery($query);
                 $product = $this->_db->loadObjectList();
             }
             if (count($product) == 0) {
                 $alias = KSFunctions::GenAlias($product_data['title']);
                 $values = array('parent_id' => $product_data['parent_id'], 'childs_group' => $product_data['childs_group'], 'title' => $this->_db->quote($product_data['title']), 'alias' => $this->_db->quote($alias), 'price' => $this->_db->quote($product_data['price']), 'old_price' => $this->_db->quote($product_data['old_price']), 'price_type' => $product_data['price_type'], 'in_stock' => $product_data['in_stock'], 'product_code' => $this->_db->quote($product_data['product_code']), 'product_packaging' => $product_data['product_packaging'], 'product_unit' => $product_data['product_unit'], 'content' => $this->_db->quote($product_data['content']), 'promotion' => $product_data['promotion'], 'manufacturer' => $product_data['manufacturer'], 'published' => 1, 'metatitle' => $this->_db->quote($product_data['metatitle']), 'metadescription' => $this->_db->quote($product_data['metadescription']), 'metakeywords' => $this->_db->quote($product_data['metakeywords']), 'date_added' => 'NOW()', 'type' => $this->_db->quote($product_data['type']));
                 $query = $this->_db->getQuery(true);
                 $query->update('#__ksenmart_products')->set('ordering=ordering+1');
                 $this->_db->setQuery($query);
                 $this->_db->query();
                 $query = $this->_db->getQuery(true);
                 $query->insert('#__ksenmart_products')->columns(implode(',', array_keys($values)))->values(implode(',', $values));
                 $this->_db->setQuery($query);
                 $this->_db->query();
                 $product_id = $this->_db->insertid();
                 $is_default = true;
                 foreach ($prd_cats as $prd_cat) {
                     $qvalues = array($product_id, $prd_cat, (int) $is_default);
                     $query = $this->_db->getQuery(true);
                     $query->insert('#__ksenmart_products_categories')->columns('product_id,category_id,is_default')->values(implode(',', $qvalues));
                     $this->_db->setQuery($query);
                     $this->_db->query();
                     $is_default = false;
                 }
                 $info['insert']++;
             } else {
                 $product_id = $product[0]->id;
                 $to_update = array();
                 $to_update[] = 'date_added=NOW()';
                 if (isset($product_data['title'])) {
                     $to_update[] = 'title=' . $this->_db->quote($product_data['title']);
                 }
                 if (isset($product_data['product_code'])) {
                     $to_update[] = 'product_code=' . $this->_db->quote($product_data['product_code']);
                 }
                 if (isset($product_data['in_stock'])) {
                     $to_update[] = 'in_stock=' . $this->_db->quote($product_data['in_stock']);
                 }
                 if (isset($product_data['content'])) {
                     $to_update[] = 'content=' . $this->_db->quote($product_data['content']);
                 }
                 if (isset($product_data['introcontent'])) {
                     $to_update[] = 'introcontent=' . $this->_db->quote($product_data['introcontent']);
                 }
                 if (isset($product_data['product_packaging'])) {
                     $to_update[] = 'product_packaging=' . $this->_db->quote($product_data['product_packaging']);
                 }
                 if ($product_data['metatitle'] != '') {
                     $to_update[] = 'metatitle=' . $this->_db->quote($product_data['metatitle']);
                 }
                 if ($product_data['metadescription'] != '') {
                     $to_update[] = 'metadescription=' . $this->_db->quote($product_data['metadescription']);
                 }
                 if ($product_data['metakeywords'] != '') {
                     $to_update[] = 'metakeywords=' . $this->_db->quote($product_data['metakeywords']);
                 }
                 if (isset($product_data['price'])) {
                     $to_update[] = 'price=' . $this->_db->quote($product_data['price']);
                 }
                 if (isset($product_data['manufacturer'])) {
                     $to_update[] = 'manufacturer=' . $this->_db->quote($product_data['manufacturer']);
                 }
                 if (isset($product_data['price_type'])) {
                     $to_update[] = 'price_type=' . $this->_db->quote($product_data['price_type']);
                 }
                 if (isset($product_data['product_unit'])) {
                     $to_update[] = 'product_unit=' . $this->_db->quote($product_data['product_unit']);
                 }
                 if (isset($product_data['old_price'])) {
                     $to_update[] = 'old_price=' . $this->_db->quote($product_data['old_price']);
                 }
                 if (isset($product_data['promotion'])) {
                     $to_update[] = 'promotion=' . $this->_db->quote($product_data['promotion']);
                 }
                 foreach ($prd_cats as $prd_cat) {
                     $query = $this->_db->getQuery(true);
                     $query->select('*')->from('#__ksenmart_products_categories')->where('product_id=' . $product_id)->where('category_id=' . $prd_cat);
                     $this->_db->setQuery($query);
                     $db_cat = $this->_db->loadObject();
                     if (count($db_cat) == 0) {
                         $qvalues = array($product_id, $prd_cat);
                         $query = $this->_db->getQuery(true);
                         $query->insert('#__ksenmart_products_categories')->columns('product_id,category_id')->values(implode(',', $qvalues));
                         $this->_db->setQuery($query);
                         $this->_db->query();
                     }
                 }
                 $query = $this->_db->getQuery(true);
                 $query->update('#__ksenmart_products')->set($to_update)->where('id=' . $product_id);
                 $this->_db->setQuery($query);
                 $this->_db->query();
                 if (isset($product_data['photos']) && $product_data['photos'] != '') {
                     $query = $this->_db->getQuery(true);
                     $query->select('*')->from('#__ksenmart_files')->where(array("media_type='image'", "owner_type='product'", "owner_id=" . $product_id))->order('ordering');
                     $this->_db->setQuery($query);
                     $images = $this->_db->loadObjectList('id');
                     $i = count($images);
                     foreach ($images as $image) {
                         $this->delPhoto($image->filename, $image->folder);
                     }
                 }
                 $info['update']++;
             }
             if (isset($product_data['relative']) && $product_data['relative'] != '') {
                 $relatives[$product_id] = $product_data['relative'];
             }
             if (isset($product_data['tags']) && $product_data['tags'] != '') {
                 $product_data['tags'] = explode(',', $product_data['tags']);
                 foreach ($product_data['tags'] as $key => $value) {
                     $value = trim($value);
                     $query = $this->_db->getQuery(true);
                     $query->select('id')->from('#__tags')->where('title=' . $this->_db->quote($value));
                     $this->_db->setQuery($query);
                     $tag_id = $this->_db->loadResult();
                     if (!empty($tag_id)) {
                         $product_data['tags'][$key] = $tag_id;
                     } else {
                         $product_data['tags'][$key] = '#new#' . $value;
                     }
                 }
                 $tableProducts = $this->getTable('Products');
                 JObserverMapper::attachAllObservers($tableProducts);
                 JObserverMapper::addObserverClassToClass('JTableObserverTags', 'KsenmartTableProducts', array('typeAlias' => 'com_ksenmart.product'));
                 $tableProducts->load($product_id);
                 $tagsObserver = $tableProducts->getObserverOfClass('JTableObserverTags');
                 $result = $tagsObserver->setNewTags($product_data['tags'], true);
             }
             if (isset($product_data['photos']) && $product_data['photos'] != '') {
                 $product_data['photos'] = explode(',', $product_data['photos']);
                 $i = 1;
                 foreach ($product_data['photos'] as $photo) {
                     $photo = trim($photo);
                     if (!empty($photo)) {
                         $file = basename($photo);
                         $nameParts = explode('.', $file);
                         $file = microtime(true) . '.' . $nameParts[count($nameParts) - 1];
                         $copied = false;
                         if (strpos($photo, 'http://') !== false) {
                             if ($photo_content = file_get_contents($photo)) {
                                 if (file_put_contents(JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'images' . DS . 'products' . DS . 'original' . DS . $file, $photo_content)) {
                                     $copied = true;
                                 }
                             }
                         } else {
                             if (file_exists(JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'import' . DS . $photo)) {
                                 if (copy(JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'import' . DS . $photo, JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'images' . DS . 'products' . DS . 'original' . DS . $file)) {
                                     $copied = true;
                                 }
                             }
                         }
                         if ($copied) {
                             $mime = mime_content_type(JPATH_ROOT . DS . 'media' . DS . 'com_ksenmart' . DS . 'images' . DS . 'products' . DS . 'original' . DS . $file);
                             $qvalues = array($product_id, $this->_db->quote('image'), $this->_db->quote('product'), $this->_db->quote('products'), $this->_db->quote($file), $this->_db->quote($mime), $this->_db->quote(''), $i);
                             $query = $this->_db->getQuery(true);
                             $query->insert('#__ksenmart_files')->columns('owner_id,media_type,owner_type,folder,filename,mime_type,title,ordering')->values(implode(',', $qvalues));
                             $this->_db->setQuery($query);
                             $this->_db->query();
                             $i++;
                         }
                     }
                 }
             }
             foreach ($properties as $property) {
                 if (isset($product_data['property_' . $property->id]) && $product_data['property_' . $property->id] != '') {
                     switch ($property->type) {
                         case 'text':
                             if ($product_data['property_' . $property->id] != '') {
                                 $query = $this->_db->getQuery(true);
                                 $query->select('*')->from('#__ksenmart_property_values')->where('property_id=' . $property->id)->where('title=' . $this->_db->quote($product_data['property_' . $property->id]));
                                 $this->_db->setQuery($query);
                                 $prop_value = $this->_db->loadObject();
                                 if (count($prop_value) == 0) {
                                     $alias = KSFunctions::GenAlias($product_data['property_' . $property->id]);
                                     $qvalues = array($property->id, $this->_db->quote($product_data['property_' . $property->id]), $this->_db->quote($alias));
                                     $query = $this->_db->getQuery(true);
                                     $query->insert('#__ksenmart_property_values')->columns('property_id,title,alias')->values(implode(',', $qvalues));
                                     $this->_db->setQuery($query);
                                     $this->_db->query();
                                     $prop_value_id = $this->_db->insertid();
                                 } else {
                                     $prop_value_id = $prop_value->id;
                                 }
                                 $query = $this->_db->getQuery(true);
                                 $query->select('*')->from('#__ksenmart_product_properties_values')->where('product_id=' . $product_id)->where('property_id=' . $property->id)->where('value_id=' . $prop_value_id);
                                 $this->_db->setQuery($query);
                                 $prod_prop_value = $this->_db->loadObject();
                                 if (count($prod_prop_value) == 0) {
                                     $qvalues = array($product_id, $property->id, $prop_value_id, $this->_db->quote($product_data['property_' . $property->id]));
                                     $query = $this->_db->getQuery(true);
                                     $query->insert('#__ksenmart_product_properties_values')->columns('product_id,property_id,value_id,text')->values(implode(',', $qvalues));
                                     $this->_db->setQuery($query);
                                     $this->_db->query();
                                 }
                             }
                             break;
                         default:
                             $prop_vals = explode(';', $product_data['property_' . $property->id]);
                             $prop_values = '';
                             foreach ($prop_vals as $prop_val) {
                                 if ($prop_val != '') {
                                     $val_parts = explode('=', $prop_val);
                                     if (count($val_parts) == 2) {
                                         $prop_val = $val_parts[0];
                                         $val_price = $val_parts[1];
                                     } else {
                                         $val_price = '';
                                     }
                                     $query = $this->_db->getQuery(true);
                                     $query->select('*')->from('#__ksenmart_property_values')->where('property_id=' . $property->id)->where('title=' . $this->_db->quote($prop_val));
                                     $this->_db->setQuery($query);
                                     $prop_value = $this->_db->loadObject();
                                     if (count($prop_value) == 0) {
                                         $alias = KSFunctions::GenAlias($prop_val);
                                         $qvalues = array($property->id, $this->_db->quote($prop_val), $this->_db->quote($alias));
                                         $query = $this->_db->getQuery(true);
                                         $query->insert('#__ksenmart_property_values')->columns('property_id,title,alias')->values(implode(',', $qvalues));
                                         $this->_db->setQuery($query);
                                         $this->_db->query();
                                         $prop_value_id = $this->_db->insertid();
                                     } else {
                                         $prop_value_id = $prop_value->id;
                                     }
                                     $query = $this->_db->getQuery(true);
                                     $query->select('*')->from('#__ksenmart_product_properties_values')->where('product_id=' . $product_id)->where('property_id=' . $property->id)->where('value_id=' . $prop_value_id);
                                     $this->_db->setQuery($query);
                                     $prod_prop_value = $this->_db->loadObject();
                                     if (count($prod_prop_value) == 0) {
                                         $qvalues = array($product_id, $property->id, $prop_value_id, $this->_db->quote($val_price));
                                         $query = $this->_db->getQuery(true);
                                         $query->insert('#__ksenmart_product_properties_values')->columns('product_id,property_id,value_id,price')->values(implode(',', $qvalues));
                                         $this->_db->setQuery($query);
                                         $this->_db->query();
                                     } else {
                                         $query = $this->_db->getQuery(true);
                                         $query->update('#__ksenmart_product_properties_values')->set('price=' . $this->_db->quote($val_price))->where('id=' . $prod_prop_value->id);
                                         $this->_db->setQuery($query);
                                         $this->_db->query();
                                     }
                                 }
                             }
                     }
                     foreach ($prd_cats as $prd_cat) {
                         $query = $this->_db->getQuery(true);
                         $query->select('id')->from('#__ksenmart_product_categories_properties')->where('category_id=' . $prd_cat)->where('property_id=' . $property->id);
                         $this->_db->setQuery($query);
                         $res = $this->_db->loadResult();
                         if (empty($res)) {
                             $qvalues = array($prd_cat, $property->id);
                             $query = $this->_db->getQuery(true);
                             $query->insert('#__ksenmart_product_categories_properties')->columns('category_id,property_id')->values(implode(',', $qvalues));
                             $this->_db->setQuery($query);
                             $this->_db->query();
                         }
                     }
                 }
             }
         }
     }
     foreach ($relatives as $product_id => $relative) {
         $relative = explode(';', $relative);
         foreach ($relative as $relative_title) {
             if (!empty($relative_title)) {
                 $query = $this->_db->getQuery(true);
                 $query->select('id')->from('#__ksenmart_products')->where('title like ' . $this->_db->quote($relative_title));
                 $this->_db->setQuery($query);
                 $relative_id = $this->_db->loadResult();
                 if (!empty($relative_id)) {
                     $query = $this->_db->getQuery(true);
                     $query->select('*')->from('#__ksenmart_products_relations')->where('product_id=' . $product_id)->where('relative_id=' . $relative_id)->where('relation_type=' . $this->_db->quote('relation'));
                     $this->_db->setQuery($query);
                     $db_rel = $this->_db->loadObject();
                     if (count($db_rel) == 0) {
                         $qvalues = array($product_id, $relative_id, $this->_db->quote('relation'));
                         $query = $this->_db->getQuery(true);
                         $query->insert('#__ksenmart_products_relations')->columns('product_id,relative_id,relation_type')->values(implode(',', $qvalues));
                         $this->_db->setQuery($query);
                         $this->_db->query();
                     }
                 }
             }
         }
     }
     fclose($f);
     $dir = scandir(JPATH_COMPONENT . DS . 'tmp' . DS);
     foreach ($dir as $d) {
         if ($d != '.' && $d != '..') {
             unlink(JPATH_COMPONENT . DS . 'tmp' . DS . $d);
         }
     }
     $this->onExecuteAfter('getImportInfo', array(&$info));
     return $info;
 }
Пример #10
0
 /**
  * Class constructor.
  *
  * @param   array  $config  A named array of configuration variables.
  *
  * @since   1.6
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     JObserverMapper::addObserverClassToClass('JTableObserverTags', 'PlayJoomTableAudioTrack', array('typeAlias' => 'com_playjoom.audiotrack'));
 }
Пример #11
0
/**
 * @package      SocialCommunity
 * @subpackage   Libraries
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2015 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
// no direct access
defined('_JEXEC') or die;
if (!defined("SOCIALCOMMUNITY_PATH_COMPONENT_ADMINISTRATOR")) {
    define("SOCIALCOMMUNITY_PATH_COMPONENT_ADMINISTRATOR", JPATH_ADMINISTRATOR . "/components/com_socialcommunity");
}
if (!defined("SOCIALCOMMUNITY_PATH_COMPONENT_SITE")) {
    define("SOCIALCOMMUNITY_PATH_COMPONENT_SITE", JPATH_SITE . "/components/com_socialcommunity");
}
if (!defined("SOCIALCOMMUNITY_PATH_LIBRARY")) {
    define("SOCIALCOMMUNITY_PATH_LIBRARY", JPATH_LIBRARIES . "/socialcommunity");
}
JLoader::registerNamespace('SocialCommunity', JPATH_LIBRARIES);
// Register helpers
JLoader::register("SocialCommunityHelper", SOCIALCOMMUNITY_PATH_COMPONENT_ADMINISTRATOR . "/helpers/socialcommunity.php");
JLoader::register("SocialCommunityHelperRoute", SOCIALCOMMUNITY_PATH_COMPONENT_SITE . "/helpers/route.php");
// Register Observers
JLoader::register("SocialCommunityObserverProfile", SOCIALCOMMUNITY_PATH_COMPONENT_ADMINISTRATOR . "/tables/observers/profile.php");
JObserverMapper::addObserverClassToClass('SocialCommunityObserverProfile', 'SocialCommunityTableProfile', array('typeAlias' => 'com_socialcommunity.profile'));
// Include HTML helpers path
JHtml::addIncludePath(SOCIALCOMMUNITY_PATH_COMPONENT_SITE . '/helpers/html');
// Load library language
$lang = JFactory::getLanguage();
$lang->load('lib_socialcommunity', SOCIALCOMMUNITY_PATH_LIBRARY);
Пример #12
0
 /**
  * Constructor
  *
  * @param   JDatabase  &$db  A database connector object
  */
 public function __construct(&$db)
 {
     JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'AkrecipesTableunit', array('typeAlias' => 'com_akrecipes.unit'));
     parent::__construct('#__akrecipes_units', 'id', $db);
 }
Пример #13
0
 /**
  * @param string $table
  * @param string $key
  * @param JDatabase $db
  */
 function __construct($table, $key, &$db)
 {
     $this->_tbl = $table;
     $this->_db =& $db;
     $this->_pkey = $key;
     if (JVM_VERSION < 3) {
         $this->_tbl_key = $key;
     } else {
         // Set the key to be an array.
         if (is_string($key)) {
             $key = array($key);
         } elseif (is_object($key)) {
             $key = (array) $key;
         }
         $this->_tbl_keys = $key;
         if (count($key) == 1) {
             $this->_autoincrement = true;
         } else {
             $this->_autoincrement = false;
         }
         // Set the singular table key for backwards compatibility.
         $this->_tbl_key = $this->getKeyName();
     }
     // If we are tracking assets, make sure an access field exists and initially set the default.
     if (property_exists($this, 'asset_id')) {
         $this->_trackAssets = true;
     }
     // If the access property exists, set the default.
     if (property_exists($this, 'access')) {
         $this->access = (int) JFactory::getConfig()->get('access');
     }
     if (JVM_VERSION > 2) {
         // Implement JObservableInterface:
         // Create observer updater and attaches all observers interested by $this class:
         $this->_observers = new JObserverUpdater($this);
         JObserverMapper::attachAllObservers($this);
     }
 }
Пример #14
0
 /**
  * Object constructor to set table and key fields.  In most cases this will
  * be overridden by child classes to explicitly set the table and key fields
  * for a particular database table.
  *
  * @param   string           $table  Name of the table to model.
  * @param   string           $key    Name of the primary key field in the table.
  * @param   JDatabaseDriver  $db     JDatabaseDriver object.
  *
  * @since   11.1
  */
 public function __construct($table, $key, $db)
 {
     // Set internal variables.
     $this->_tbl = $table;
     $this->_tbl_key = $key;
     $this->_db = $db;
     // Initialise the table properties.
     $fields = $this->getFields();
     if ($fields) {
         foreach ($fields as $name => $v) {
             // Add the field if it is not already present.
             if (!property_exists($this, $name)) {
                 $this->{$name} = null;
             }
         }
     }
     // If we are tracking assets, make sure an access field exists and initially set the default.
     if (property_exists($this, 'asset_id')) {
         $this->_trackAssets = true;
     }
     // If the access property exists, set the default.
     if (property_exists($this, 'access')) {
         $this->access = (int) JFactory::getConfig()->get('access');
     }
     // Implement JObservableInterface:
     // Create observer updater and attaches all observers interested by $this class:
     $this->_observers = new JObserverUpdater($this);
     JObserverMapper::attachAllObservers($this);
 }
Пример #15
0
	define('JVERSION', $jversion->getShortVersion());
}

// Set up the message queue logger for web requests
if (array_key_exists('REQUEST_METHOD', $_SERVER))
{
	JLog::addLogger(array('logger' => 'messagequeue'), JLog::ALL, array('jerror'));
}

// Register classes where the names have been changed to fit the autoloader rules
// @deprecated  4.0
JLoader::register('JToolBar', JPATH_PLATFORM . '/cms/toolbar/toolbar.php');
JLoader::register('JButton',  JPATH_PLATFORM . '/cms/toolbar/button.php');
JLoader::register('JInstallerComponent',  JPATH_PLATFORM . '/cms/installer/adapter/component.php');
JLoader::register('JInstallerFile',  JPATH_PLATFORM . '/cms/installer/adapter/file.php');
JLoader::register('JInstallerLanguage',  JPATH_PLATFORM . '/cms/installer/adapter/language.php');
JLoader::register('JInstallerLibrary',  JPATH_PLATFORM . '/cms/installer/adapter/library.php');
JLoader::register('JInstallerModule',  JPATH_PLATFORM . '/cms/installer/adapter/module.php');
JLoader::register('JInstallerPackage',  JPATH_PLATFORM . '/cms/installer/adapter/package.php');
JLoader::register('JInstallerPlugin',  JPATH_PLATFORM . '/cms/installer/adapter/plugin.php');
JLoader::register('JInstallerTemplate',  JPATH_PLATFORM . '/cms/installer/adapter/template.php');
JLoader::register('JExtension',  JPATH_PLATFORM . '/cms/installer/extension.php');

// Register Observers:
// Add Tags to Content, Contact, NewsFeeds, WebLinks and Categories: (this is the only link between them here!):
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'JTableContent', array('typeAlias' => 'com_content.article'));
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'ContactTableContact', array('typeAlias' => 'com_contact.contact'));
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'NewsfeedsTableNewsfeed', array('typeAlias' => 'com_newsfeeds.newsfeed'));
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'WeblinksTableWeblink', array('typeAlias' => 'com_weblinks.weblink'));
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'JTableCategory', array('typeAlias' => '{extension}.category'));
Пример #16
0
<?php

/**
 * @package      Gamification Platform
 * @subpackage   Components
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2016 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      GNU General Public License version 3 or later; see LICENSE.txt
 */
use Joomla\Utilities\ArrayHelper;
// no direct access
defined('_JEXEC') or die;
// Register Observers
JLoader::register('GamificationObserverReward', GAMIFICATION_PATH_COMPONENT_ADMINISTRATOR . '/tables/observers/reward.php');
JObserverMapper::addObserverClassToClass('GamificationObserverReward', 'GamificationTableReward', array('typeAlias' => 'com_gamification.reward'));
class GamificationModelReward extends JModelAdmin
{
    /**
     * Returns a reference to the a Table object, always creating it.
     *
     * @param   string $type   The table type to instantiate
     * @param   string $prefix A prefix for the table class name. Optional.
     * @param   array  $config Configuration array for model. Optional.
     *
     * @return  GamificationTableReward
     * @since   1.6
     */
    public function getTable($type = 'Reward', $prefix = 'GamificationTable', $config = array())
    {
        return JTable::getInstance($type, $prefix, $config);
    }
Пример #17
0
/**
 * @package      UserIdeas
 * @subpackage   Initialization
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2015 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
// no direct access
defined('_JEXEC') or die;
if (!defined("USERIDEAS_PATH_COMPONENT_ADMINISTRATOR")) {
    define("USERIDEAS_PATH_COMPONENT_ADMINISTRATOR", JPATH_ADMINISTRATOR . "/components/com_userideas");
}
if (!defined("USERIDEAS_PATH_COMPONENT_SITE")) {
    define("USERIDEAS_PATH_COMPONENT_SITE", JPATH_SITE . "/components/com_userideas");
}
if (!defined("USERIDEAS_PATH_LIBRARY")) {
    define("USERIDEAS_PATH_LIBRARY", JPATH_LIBRARIES . "/userideas");
}
jimport('joomla.utilities.arrayhelper');
// Register Component libraries
JLoader::register("UserIdeasConstants", USERIDEAS_PATH_LIBRARY . "/constants.php");
JLoader::register("UserIdeasVersion", USERIDEAS_PATH_LIBRARY . "/version.php");
JLoader::register("UserIdeasCategories", USERIDEAS_PATH_LIBRARY . "/categories.php");
// Register helpers
JLoader::register("UserIdeasHelper", USERIDEAS_PATH_COMPONENT_ADMINISTRATOR . "/helpers/userideas.php");
JLoader::register("UserIdeasHelperRoute", USERIDEAS_PATH_COMPONENT_SITE . "/helpers/route.php");
// Register Observers
JLoader::register("UserIdeasObserverVote", USERIDEAS_PATH_COMPONENT_ADMINISTRATOR . "/tables/observers/vote.php");
JObserverMapper::addObserverClassToClass('UserIdeasObserverVote', 'UserIdeasTableVote', array('typeAlias' => 'com_userideas.vote'));
// Include HTML helpers
JHtml::addIncludePath(USERIDEAS_PATH_COMPONENT_SITE . "/helpers/html");
<?php

/**
 * @package      Gamification Platform
 * @subpackage   Components
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2016 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      GNU General Public License version 3 or later; see LICENSE.txt
 */
// no direct access
defined('_JEXEC') or die;
// Register Observers
JLoader::register('GamificationObserverAchievement', GAMIFICATION_PATH_COMPONENT_ADMINISTRATOR . '/tables/observers/achievement.php');
JObserverMapper::addObserverClassToClass('GamificationObserverAchievement', 'GamificationTableAchievement', array('typeAlias' => 'com_gamification.achievement'));
class GamificationModelAchievement extends JModelAdmin
{
    /**
     * Returns a reference to the a Table object, always creating it.
     *
     * @param   string $type   The table type to instantiate
     * @param   string $prefix A prefix for the table class name. Optional.
     * @param   array  $config Configuration array for model. Optional.
     *
     * @return  GamificationTableAchievement
     * @since   1.6
     */
    public function getTable($type = 'Achievement', $prefix = 'GamificationTable', $config = array())
    {
        return JTable::getInstance($type, $prefix, $config);
    }
    /**
Пример #19
0
<?php

/**
* @package      ProofOfIdentity
* @subpackage   Library
* @author       Todor Iliev
* @copyright    Copyright (C) 2015 Todor Iliev <*****@*****.**>. All rights reserved.
* @license      http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('JPATH_PLATFORM') or die;
if (!defined("IDENTITYPROOF_PATH_COMPONENT_ADMINISTRATOR")) {
    define("IDENTITYPROOF_PATH_COMPONENT_ADMINISTRATOR", JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . "components" . DIRECTORY_SEPARATOR . "com_identityproof");
}
if (!defined("IDENTITYPROOF_PATH_COMPONENT_SITE")) {
    define("IDENTITYPROOF_PATH_COMPONENT_SITE", JPATH_SITE . DIRECTORY_SEPARATOR . "components" . DIRECTORY_SEPARATOR . "com_identityproof");
}
if (!defined("IDENTITYPROOF_PATH_LIBRARY")) {
    define("IDENTITYPROOF_PATH_LIBRARY", JPATH_LIBRARIES . DIRECTORY_SEPARATOR . "identityproof");
}
// Register version and constants
JLoader::register("IdentityProofVersion", IDENTITYPROOF_PATH_LIBRARY . DIRECTORY_SEPARATOR . "version.php");
JLoader::register("IdentityProofConstants", IDENTITYPROOF_PATH_LIBRARY . DIRECTORY_SEPARATOR . "constants.php");
// Register helpers
JLoader::register("IdentityProofHelper", IDENTITYPROOF_PATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . "helpers" . DIRECTORY_SEPARATOR . "identityproof.php");
JLoader::register("IdentityProofHelperRoute", IDENTITYPROOF_PATH_COMPONENT_SITE . "/helpers/route.php");
// Register Observers
JLoader::register("IdentityProofObserverFile", IDENTITYPROOF_PATH_COMPONENT_ADMINISTRATOR . "/tables/observers/file.php");
JObserverMapper::addObserverClassToClass('IdentityProofObserverFile', 'IdentityProofTableFile', array('typeAlias' => 'com_identityproof.file'));
// Register HTML helpers
JHtml::addIncludePath(IDENTITYPROOF_PATH_COMPONENT_SITE . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'html');
JLoader::register('JHtmlString', JPATH_LIBRARIES . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'string.php');
Пример #20
0
<?php

/**
 * @package      Gamification Platform
 * @subpackage   Components
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2016 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      GNU General Public License version 3 or later; see LICENSE.txt
 */
use Joomla\Utilities\ArrayHelper;
use Joomla\Registry\Registry;
// no direct access
defined('_JEXEC') or die;
// Register Observers
JLoader::register('GamificationObserverBadge', GAMIFICATION_PATH_COMPONENT_ADMINISTRATOR . '/tables/observers/badge.php');
JObserverMapper::addObserverClassToClass('GamificationObserverBadge', 'GamificationTableBadge', array('typeAlias' => 'com_gamification.badge'));
class GamificationModelBadge extends JModelAdmin
{
    /**
     * Returns a reference to the a Table object, always creating it.
     *
     * @param   string $type   The table type to instantiate
     * @param   string $prefix A prefix for the table class name. Optional.
     * @param   array  $config Configuration array for model. Optional.
     *
     * @return  GamificationTableBadge  A database object
     * @since   1.6
     */
    public function getTable($type = 'Badge', $prefix = 'GamificationTable', $config = array())
    {
        return JTable::getInstance($type, $prefix, $config);
Пример #21
0
 /**
  * Constructor
  *
  * @param JDatabase A database connector object
  */
 public function __construct(&$db)
 {
     parent::__construct('#__dzproduct_items', 'id', $db);
     JTableObserverTags::createObserver($this, array('typeAlias' => 'com_dzproduct.item'));
     JObserverMapper::addObserverClassToClass('JTableObserverTags', 'DZProductTableItem', array('typeAlias' => 'com_dzproduct.item'));
 }
Пример #22
0
require_once JPATH_COMPONENT . '/base/loader.php';
//defines CKEDITOR library includes path
define('CKEDITOR_LIBRARY', JPATH_PLUGINS . '/editors/arkeditor/ckeditor');
define('ARKEDITOR_COMPONENT', JURI::root() . 'administrator/components/com_arkeditor');
//load  default style sheets
$document = JFactory::getDocument();
$document->addStyleSheet(ARKEDITOR_COMPONENT . '/css/header.css', 'text/css');
arkimport('base.controller');
//now load in JBrowser class as it is now needed
jimport('joomla.environment.browser');
//register all event listeners
ARKRegisterAllEventlisetners();
$app = JFactory::getApplication();
//Map table observers
require_once JPATH_COMPONENT . '/tables/observer/plugin.php';
JObserverMapper::addObserverClassToClass('JTableObserverARKPlugin', 'ARKTablePlugin');
$controllername = '';
$task = $app->input->get('task', '');
if (strpos($task, '.')) {
    list($controllername, $task) = explode('.', $task);
}
if ($controllername) {
    $app->input->set('controller', $controllername);
}
//Make sure we load in system language file for component
$lang = JFactory::getLanguage();
$component = 'com_arkeditor.sys';
$lang->load($component, JPATH_ADMINISTRATOR);
require_once 'helper.php';
//$view = $app->input->get('view','cpanel' );
if (!is_dir(CKEDITOR_LIBRARY)) {
Пример #23
0
 /**
  * Set observer to the team table
  *
  * @return  void
  *
  * @since   3.0
  */
 public function onAfterInitialise()
 {
     JObserverMapper::addObserverClassToClass('JTableObserverJdswatcher', 'JTableTeams', array('typeAlias' => 'com_joomsport.team'));
 }
Пример #24
0
if (!defined("CROWDFUNDING_PATH_COMPONENT_ADMINISTRATOR")) {
    define("CROWDFUNDING_PATH_COMPONENT_ADMINISTRATOR", JPATH_ADMINISTRATOR . "/components/com_crowdfunding");
}
if (!defined("CROWDFUNDING_PATH_COMPONENT_SITE")) {
    define("CROWDFUNDING_PATH_COMPONENT_SITE", JPATH_SITE . "/components/com_crowdfunding");
}
if (!defined("CROWDFUNDING_PATH_LIBRARY")) {
    define("CROWDFUNDING_PATH_LIBRARY", JPATH_LIBRARIES . "/Crowdfunding");
}
JLoader::registerNamespace('Crowdfunding', JPATH_LIBRARIES);
// Register some helpers
JLoader::register("CrowdfundingHelper", CROWDFUNDING_PATH_COMPONENT_ADMINISTRATOR . "/helpers/crowdfunding.php");
JLoader::register("CrowdfundingHelperRoute", CROWDFUNDING_PATH_COMPONENT_SITE . "/helpers/route.php");
// Register some Joomla! classes
JLoader::register('JHtmlString', JPATH_LIBRARIES . "/joomla/html/html/string.php");
JLoader::register("JHtmlCategory", JPATH_LIBRARIES . "/joomla/html/html/category.php");
// Include HTML helpers path
JHtml::addIncludePath(CROWDFUNDING_PATH_COMPONENT_SITE . '/helpers/html');
// Register Observers
JLoader::register("CrowdfundingObserverReward", CROWDFUNDING_PATH_COMPONENT_ADMINISTRATOR . "/tables/observers/reward.php");
JObserverMapper::addObserverClassToClass('CrowdfundingObserverReward', 'CrowdfundingTableReward', array('typeAlias' => 'com_crowdfunding.reward'));
// Prepare logger
$registry = Joomla\Registry\Registry::getInstance("com_crowdfunding");
/** @var  $registry Joomla\Registry\Registry */
$registry->set("logger.table", "#__crowdf_logs");
$registry->set("logger.file", "com_crowdfunding.php");
// Load library language
$lang = JFactory::getLanguage();
$lang->load('lib_crowdfunding', CROWDFUNDING_PATH_LIBRARY);
// Register class aliases.
JLoader::registerAlias('CrowdfundingCategories', '\\Crowdfunding\\Categories');
Пример #25
0
 /**
  * Object constructor to set table and key fields.  In most cases this will
  * be overridden by child classes to explicitly set the table and key fields
  * for a particular database table.
  *
  * @param   string           $table  Name of the table to model.
  * @param   mixed            $key    Name of the primary key field in the table or array of field names that compose the primary key.
  * @param   JDatabaseDriver  $db     JDatabaseDriver object.
  *
  * @since   11.1
  */
 public function __construct($table, $key, $db)
 {
     // Set internal variables.
     $this->_tbl = $table;
     // Set the key to be an array.
     if (is_string($key)) {
         $key = array($key);
     } elseif (is_object($key)) {
         $key = (array) $key;
     }
     $this->_tbl_keys = $key;
     if (count($key) == 1) {
         $this->_autoincrement = true;
     } else {
         $this->_autoincrement = false;
     }
     // Set the singular table key for backwards compatibility.
     $this->_tbl_key = $this->getKeyName();
     $this->_db = $db;
     // Initialise the table properties.
     $fields = $this->getFields();
     if ($fields) {
         foreach ($fields as $name => $v) {
             // Add the field if it is not already present.
             if (!property_exists($this, $name)) {
                 $this->{$name} = null;
             }
         }
     }
     // If we are tracking assets, make sure an access field exists and initially set the default.
     if (property_exists($this, 'asset_id')) {
         $this->_trackAssets = true;
     }
     // If the access property exists, set the default.
     if (property_exists($this, 'access')) {
         $this->access = (int) JFactory::getConfig()->get('access');
     }
     // Implement JObservableInterface:
     // Create observer updater and attaches all observers interested by $this class:
     $this->_observers = new JObserverUpdater($this);
     JObserverMapper::attachAllObservers($this);
 }
Пример #26
0
 /**
  * Helper wrapper method for attachAllObservers
  *
  * @param   JObservableInterface  $observableObject  The observable subject object.
  *
  * @return void
  *
  * @see     JObserverMapper::attachAllObservers
  * @since   3.4
  */
 public function attachAllObservers(JObservableInterface $observableObject)
 {
     return JObserverMapper::attachAllObservers($observableObject);
 }
Пример #27
0
 /**
  * Constructor
  *
  * @param   JDatabase  &$db  A database connector object
  */
 public function __construct(&$db)
 {
     JObserverMapper::addObserverClassToClass('JTableObserverContenthistory', 'VocabTablecontent', array('typeAlias' => 'com_vocab.content'));
     parent::__construct('#__vocab_content', 'id', $db);
 }
Пример #28
0
 * @subpackage   Plugins
 * @author       Todor Iliev
 * @copyright    Copyright (C) 2016 Todor Iliev <*****@*****.**>. All rights reserved.
 * @license      GNU General Public License version 3 or later; see LICENSE.txt
 */
use Crowdfunding\Transaction\Transaction;
use Crowdfunding\Transaction\TransactionManager;
use Crowdfunding\Reward;
use Joomla\Utilities\ArrayHelper;
// no direct access
defined('_JEXEC') or die;
jimport('Prism.init');
jimport('Crowdfunding.init');
jimport('Crowdfundingfinance.init');
jimport('Emailtemplates.init');
JObserverMapper::addObserverClassToClass('Crowdfunding\\Observer\\Transaction\\TransactionObserver', 'Crowdfunding\\Transaction\\TransactionManager', array('typeAlias' => 'com_crowdfunding.payment'));
/**
 * Crowdfunding PayPal payment plugin.
 *
 * @package      Crowdfunding
 * @subpackage   Plugins
 */
class plgCrowdfundingPaymentPayPal extends Crowdfunding\Payment\Plugin
{
    public function __construct(&$subject, $config = array())
    {
        $this->serviceProvider = 'PayPal';
        $this->serviceAlias = 'paypal';
        $this->extraDataKeys = array('first_name', 'last_name', 'payer_id', 'payer_status', 'mc_gross', 'mc_fee', 'mc_currency', 'payment_status', 'payment_type', 'payment_date', 'txn_type', 'test_ipn', 'ipn_track_id', 'custom', 'protection_eligibility');
        parent::__construct($subject, $config);
    }
Пример #29
0
 /**
  * @param string $table
  * @param string $key
  * @param JDatabase $db
  */
 function __construct($table, $key, &$db)
 {
     $this->_tbl = $table;
     $this->_db =& $db;
     $this->_pkey = $key;
     /*$fields=$db->getTableColumns($this->_tbl);
     		foreach($fields as $field=>$type)
     		{
     			$this->$field=null;
     		}*/
     $this->_pkeyForm = 'cid';
     if (JVM_VERSION < 3) {
         $this->_tbl_key = $key;
         $this->_tbl_keys = array($key);
     } else {
         // Set the key to be an array.
         if (is_string($key)) {
             $key = array($key);
         } elseif (is_object($key)) {
             $key = (array) $key;
         }
         $this->_tbl_keys = $key;
         $this->_tbl_key = $key[0];
         if (count($key) == 1) {
             $this->_autoincrement = true;
         } else {
             $this->_autoincrement = false;
         }
     }
     // If we are tracking assets, make sure an access field exists and initially set the default.
     if (property_exists($this, 'asset_id')) {
         $this->_trackAssets = true;
     }
     // If the access property exists, set the default.
     if (property_exists($this, 'access')) {
         $this->access = (int) JFactory::getConfig()->get('access');
     }
     if (JVM_VERSION > 2) {
         // Implement JObservableInterface:
         // Create observer updater and attaches all observers interested by $this class:
         $this->_observers = new JObserverUpdater($this);
         JObserverMapper::attachAllObservers($this);
     }
 }
Пример #30
0
<?php

/**
* @package      CrowdfundingFiles
* @subpackage   Library
* @author       Todor Iliev
* @copyright    Copyright (C) 2015 Todor Iliev <*****@*****.**>. All rights reserved.
* @license      http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
defined('JPATH_PLATFORM') or die;
if (!defined("CROWDFUNDINGFILES_PATH_COMPONENT_ADMINISTRATOR")) {
    define("CROWDFUNDINGFILES_PATH_COMPONENT_ADMINISTRATOR", JPATH_ADMINISTRATOR . "/components/com_crowdfundingfiles");
}
if (!defined("CROWDFUNDINGFILES_PATH_COMPONENT_SITE")) {
    define("CROWDFUNDINGFILES_PATH_COMPONENT_SITE", JPATH_SITE . "/components/com_crowdfundingfiles");
}
if (!defined("CROWDFUNDINGFILES_PATH_LIBRARY")) {
    define("CROWDFUNDINGFILES_PATH_LIBRARY", JPATH_LIBRARIES . "/crowdfundingfiles");
}
JLoader::registerNamespace('CrowdfundingFiles', JPATH_LIBRARIES);
// Register helpers
JLoader::register("CrowdfundingFilesHelper", CROWDFUNDINGFILES_PATH_COMPONENT_ADMINISTRATOR . "/helpers/crowdfundingfiles.php");
// Register HTML helpers
JHtml::addIncludePath(CROWDFUNDINGFILES_PATH_COMPONENT_SITE . "/helpers/html");
JLoader::register('JHtmlString', JPATH_LIBRARIES . "/joomla/html/html/string.php");
// Register Observers
JLoader::register("CrowdfundingFilesObserverFile", CROWDFUNDINGFILES_PATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . "tables" . DIRECTORY_SEPARATOR . "observers" . DIRECTORY_SEPARATOR . "file.php");
JObserverMapper::addObserverClassToClass('CrowdfundingFilesObserverFile', 'CrowdfundingFilesTableFile', array('typeAlias' => 'com_crowdfundingfiles.file'));