/**
  * Create default store on install
  * */
 function createSuperuserstore()
 {
     $storeMsg = array();
     // CHECK EXISTANCE OF DEFAULT STORE
     $db = JFactory::getDBO();
     $query = "SELECT `id`,`extra` FROM `#__kart_store` WHERE `extra` IS NOT NULL";
     $db->setQuery($query);
     $storedata = $db->loadAssocList();
     $default_store = 0;
     foreach ($storedata as $data) {
         $extraField = json_decode($data['extra'], 1);
         if (!empty($extraField['default'])) {
             $default_store = $data['id'];
             break;
         }
     }
     // if no default store is found then create
     if (empty($default_store)) {
         $product_path = JPATH_SITE . '/components/com_quick2cart/models/vendor.php';
         if (!class_exists('quick2cartModelVendor')) {
             //require_once $path;
             JLoader::register('quick2cartModelVendor', $product_path);
             JLoader::load('quick2cartModelVendor');
         }
         $user = JFactory::getUser();
         global $mainframe;
         $mainframe = JFactory::getApplication();
         $jinput = $mainframe->input;
         $post = $jinput->post;
         //$post=array();
         $sitename = $mainframe->getCfg('sitename');
         $post->set('title', $sitename);
         $post->set('description', '');
         $post->set('companyname', '');
         $post->set('address', '');
         $post->set('phone', '');
         $post->set('email', $mainframe->getCfg('mailfrom'));
         $post->set('paymentMode', 1);
         $post->set('otherPayMethod', $mainframe->getCfg('mailfrom'));
         $post->set('storeVanityUrl', '');
         $extraArray = array();
         $extraArray['default'] = 1;
         $extraArray = json_encode($extraArray);
         $post->set('extra', $extraArray);
         $avtar_path = 'components/com_quick2cart/images/no_user.png';
         $post->set('avatar', $avtar_path);
         $storeheader_path = 'components/com_quick2cart/images/header_default2.jpg';
         $post->set('storeheader', $storeheader_path);
         $quick2cartModelVendor = new quick2cartModelVendor();
         $quick2cartModelVendor->store($post);
         $default_store = $sitename . " ( Default Store ) ";
         $storeMsg[$default_store] = "Created";
         //JText::_("COM_QUICK2CART_ADDED_STORE_ON_INSTALL_MSG");;
         return $storeMsg;
     }
 }
Beispiel #2
0
 /**
  * Front end:: This function gives formatted vanity url
  * @param Title :: storeTitle
  * @param $oldstore_id :: $oldstore_id (on edit used to compare with old store id)
  * */
 function formatttedTitle($title, $oldstore_id = '')
 {
     $db = JFactory::getDBO();
     $quick2cartModelVendor = new quick2cartModelVendor();
     $user = JFactory::getUser();
     $i = 1;
     $final_title = $title;
     do {
         if ($i == 1) {
             $status = $quick2cartModelVendor->ckUniqueStoretitle($title, $oldstore_id);
         } else {
             $final_title = $title . $i;
             $status = $quick2cartModelVendor->ckUniqueStoretitle($final_title);
         }
         // generate new vanity url
         $i++;
     } while ($status != 0);
     return $db->escape(trim($final_title), true);
 }
 /**
  * Sneha and vk change for plugin- create new store according to user
  *
  * @param   Object  $post    post    obj.
  * @param   String  $userid  userid  userid.
  *
  * @since   2.2
  * @return   post obj.
  */
 public function saveVendorDetails($post, $userid = '')
 {
     // Modified for vk-sneha change
     if (empty($userid)) {
         $user = JFactory::getUser();
         $userid = $user->id;
     }
     // START Q2C Sample development
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('system');
     $result = $dispatcher->trigger('qtcOnBeforeSaveStore', array($post));
     $beforecart = '';
     if (!empty($result)) {
         $post = $result[0];
     }
     JLoader::import('vendor', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_quick2cart' . DS . 'models');
     $model = new quick2cartModelVendor();
     $result = $model->store($post, $userid);
     if (!empty($result)) {
         // START Q2C Sample development
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('system');
         $plgresult = $dispatcher->trigger('qtcOnAfterSaveStore', array($post, $result));
         $msg = JText::_('COM_QUICK2CART_STOREC_SAVE_M_S');
     } else {
         $msg = JText::_('COM_QUICK2CART_STOREC_SAVE_M_NS');
     }
     $return = array();
     $return['store_id'] = $result;
     $return['msg'] = $msg;
     return $return;
 }