/**
  * @testdox  Tests that message and message type set in setMessage() are overriden by setRedirect()
  *
  * @covers   JControllerLegacy::setRedirect
  */
 public function testSetRedirectWithUrlNoMessageAndMessageTypeWithPreviouslySetMessage()
 {
     $this->class->setMessage('Folks?', 'notice');
     $this->class->setRedirect('index.php?option=com_foobar', null, 'question');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class);
     $this->assertAttributeEquals('Folks?', 'message', $this->class);
     $this->assertAttributeEquals('question', 'messageType', $this->class);
 }
Пример #2
0
 public function display($tpl = null)
 {
     if (!function_exists('curl_version')) {
         $contr = new JControllerLegacy();
         $contr->setRedirect('index.php?option=com_mobilize&task=position.selectPosition');
         $contr->redirect();
     }
     $this->setFilterable(false);
     $document = JFactory::getDocument();
     $document->addScript(JURI::root(true) . '/media/jui/js/jquery.js');
     if (isset($this->filterEnabled) and $this->filterEnabled) {
         JSNHtmlAsset::addScript(JSN_MOBILIZE_ASSETS_URL . '/js/jsn.jquery.noconflict.js');
     }
     /**
      * When position clicked
      * object returned after this event fired is
      * clicked position
      * Use $(this)
      */
     $onPostionClick = "\n\t\t\tif ( !\$(this).hasClass('active-position') ){\n\t\t\t\twindow.parent.jQuery.jSelectPosition(\$(this).find('p').text());\t\t\t\t\n\t\t\t}\n\t\t";
     $this->addPositionClickCallBack($onPostionClick);
     parent::display($tpl);
 }
Пример #3
0
 /**
  * Set the redirect url
  *
  * @param   string  $url   default url
  * @param   string  $msg   optional message to apply on redirect
  * @param   string  $type  optional message type
  *
  * @return  null
  */
 public function setRedirect($url, $msg = null, $type = 'message')
 {
     $session = JFactory::getSession();
     $app = JFactory::getApplication();
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     $formdata = $session->get('com_' . $package . '.form.data');
     $context = 'com_' . $package . '.form.' . $formdata['fabrik'] . '.redirect.';
     // If the redirect plug-in has set a url use that in preference to the default url
     $surl = $session->get($context . 'url', array($url));
     if (!is_array($surl)) {
         $surl = array($surl);
     }
     if (empty($surl)) {
         $surl[] = $url;
     }
     $smsg = $session->get($context . 'msg', array($msg));
     if (!is_array($smsg)) {
         $smsg = array($smsg);
     }
     if (empty($smsg)) {
         $smsg[] = $msg;
     }
     $url = array_shift($surl);
     $msg = array_shift($smsg);
     $app = JFactory::getApplication();
     $q = $app->getMessageQueue();
     $found = false;
     foreach ($q as $m) {
         // Custom message already queued - unset default msg
         if ($m['type'] == 'message' && trim($m['message']) !== '') {
             $found = true;
             break;
         }
     }
     if ($found) {
         $msg = null;
     }
     $session->set($context . 'url', $surl);
     $session->set($context . 'msg', $smsg);
     $showmsg = array_shift($session->get($context . 'showsystemmsg', array(true)));
     $msg = $showmsg ? $msg : null;
     parent::setRedirect($url, $msg, $type);
 }
Пример #4
0
 function _checkUser()
 {
     $app = JFactory::getApplication();
     // active user
     $user = JFactory::getUser();
     // check referre ID
     $referrerid = @$_SESSION['referrerid'];
     if (!$user->id || !$referrerid) {
         $msg = JText::_('ALERTNOTAUTH');
         JControllerLegacy::setRedirect('index.php', $msg);
         JControllerLegacy::redirect();
     } else {
         return $referrerid;
     }
 }
Пример #5
0
 function _loadPluginElements($xmlFile)
 {
     if (substr(strtolower($xmlFile), -4) != ".xml") {
         return;
     }
     $app = JFactory::getApplication();
     $error = "";
     // XML library
     //jimport('joomla.utilities.simplexml');
     // Import file dependencies
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . 'includes' . DS . 'simplexml.php';
     //$xmlDoc =  JFactory::getXMLParser('Simple');
     $xmlDoc = new JSimpleXML();
     $_xmlFile = JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . 'plugins' . DS . $xmlFile;
     $pos = strrpos($_xmlFile, DS);
     if ($pos) {
         $_installPath = substr($_xmlFile, 0, $pos);
     }
     if ($xmlDoc->loadFile($_xmlFile)) {
         $root =& $xmlDoc->document;
         if ($root->name() == 'alphauserpoints') {
             $element = $root->rule;
             $nameRule = $element ? $element[0]->data() : '';
             $element = $root->description;
             $descriptionRule = $element ? $element[0]->data() : '';
             $element = $root->component;
             $componentRule = $element ? $element[0]->data() : '';
             $element = $root->plugin_function;
             $pluginRule = $element ? $element[0]->data() : '';
             $element = $root->fixed_points;
             $fixedpointsRule = $element ? $element[0]->data() : '';
             $fixedpointsRule = trim(strtolower($fixedpointsRule));
             $fixedpointsRule = $fixedpointsRule == 'true' ? 1 : 0;
             $element = @$root->category;
             $categoryRule = @$element ? @$element[0]->data() : '';
             $element = @$root->display_message;
             $displayMessage = @$element ? @$element[0]->data() : '';
             $displayMessage = trim(strtolower($displayMessage));
             $displayMessage = $displayMessage == 'true' ? 1 : 0;
             $element = @$root->email_notification;
             $emailNotification = @$element ? @$element[0]->data() : '';
             $emailNotification = trim(strtolower($emailNotification));
             $emailNotification = $emailNotification == 'true' ? 1 : 0;
             // insert in table
             if ($nameRule != '' && $descriptionRule != '' && $componentRule != '' && $pluginRule != '') {
                 $db = JFactory::getDBO();
                 // check if already exist...
                 $query = "SELECT COUNT(*) FROM #__alpha_userpoints_rules WHERE `plugin_function`='{$pluginRule}'";
                 $db->setQuery($query);
                 $resultCount = $db->loadResult();
                 if (!$resultCount) {
                     $query = "INSERT INTO #__alpha_userpoints_rules VALUES ('', '" . $nameRule . "', '" . $descriptionRule . "', '" . $componentRule . "', '" . $pluginRule . "', '1', '" . $componentRule . "', '', '', '0', '0', 0, '0000-00-00 00:00:00', '', '', '', '', '0', '0', '0', '0', '1', '" . $fixedpointsRule . "', '" . $categoryRule . "', '" . $displayMessage . "', '', '0', '" . $emailNotification . "', '', '', '0', '0', '0', '0', '0', '1')";
                     $db->setQuery($query);
                     if ($db->query()) {
                         $msg = JText::_('AUP_NEW_RULE_INSTALLED_SUCCESSFULLY') . ' : <b>' . $nameRule . '</b>';
                         $app->enqueueMessage($msg);
                     } else {
                         $error = JText::_('This rule is not installed properly');
                         JError::raiseNotice(0, $error);
                     }
                 } else {
                     $error = JText::_('AUP_THISRULEALREADYEXIST');
                     JError::raiseNotice(0, $error);
                 }
             } else {
                 $error = JText::_('AUP_XML_FILE_INVALID');
                 JError::raiseWarning(0, $error);
             }
         } elseif ($root->name() == 'extension') {
             // Install standard plugins for Joomla!
             jimport('joomla.installer.installer');
             jimport('joomla.filesystem.folder');
             jimport('joomla.filesystem.file');
             $plugin_installer = new JInstaller();
             $installStandard = $plugin_installer->install($_installPath);
             JFolder::delete($_installPath);
             $redirecturl = "index.php?option=com_plugins";
             JControllerLegacy::setRedirect($redirecturl);
             JControllerLegacy::redirect();
         } else {
             unset($xmlDoc);
             $error = JText::_('AUP_XML_FILE_INVALID');
             JError::raiseWarning(0, $error);
         }
     } else {
         unset($xmlDoc);
         $error = JText::_('AUP_XML_FILE_INVALID');
         JError::raiseWarning(0, $error);
     }
 }
Пример #6
0
 function _save_coupongenerator()
 {
     $app = JFactory::getApplication();
     // initialize variables
     $db = JFactory::getDBO();
     $post = JRequest::get('post');
     $numbercouponcode = JFactory::getApplication()->input->get('numbercouponcode', 20, 'int');
     $numrandomchars = JFactory::getApplication()->input->get('numrandomchars', 0, 'int');
     $enabledincrement = intval(JFactory::getApplication()->input->get('enabledincrement', 0, 'int'));
     if ($post['points']) {
         for ($i = 0, $n = $numbercouponcode; $i < $n; $i++) {
             $row = JTable::getInstance('coupons');
             $row->id = NULL;
             $couponcode = "";
             $couponcode .= $post['prefixcouponcode'];
             if ($numrandomchars) {
                 $couponcode .= $this->createRandomCode($numrandomchars);
             }
             if ($enabledincrement) {
                 $couponcode .= $i + 1;
             }
             $row->couponcode = $couponcode;
             $row->description = $post['description'];
             $row->points = $post['points'];
             $row->expires = $post['expires'];
             $row->public = $post['public'];
             $row->printable = $post['printable'];
             if ($couponcode != '') {
                 if (!$row->store()) {
                     echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
                     exit;
                 }
                 if ($post['printable'] == 1) {
                     // save QRCode png
                     $pathQR = JPATH_COMPONENT . DS . 'assets' . DS . 'coupons' . DS . 'QRcode';
                     $urlQR = JURI::root() . 'index.php?option=com_alphauserpoints&view=registerqrcode&QRcode=' . $couponcode;
                     createURLQRcodePNG($urlQR, 50, $pathQR . DS . '50' . DS . $couponcode . '.png');
                     createURLQRcodePNG($urlQR, 250, $pathQR . DS . '250' . DS . $couponcode . '.png');
                 }
             }
         }
     }
     $msg = JText::_('AUP_DETAILSSAVED');
     JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&task=couponcodes', $msg);
     JControllerLegacy::redirect();
 }
 /**
  * Test JControllerLegacy::setRedirect
  *
  * @since   11.3
  *
  * @return  void
  */
 public function testSetRedirect()
 {
     // Set the URL only
     $this->class->setRedirect('index.php?option=com_foobar');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect.');
     $this->assertAttributeEquals(null, 'message', $this->class, 'Checks the message.');
     $this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type.');
     // Set the URL and message
     $this->class->setRedirect('index.php?option=com_foobar', 'Hello World');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (2).');
     $this->assertAttributeEquals('Hello World', 'message', $this->class, 'Checks the message (2).');
     $this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type (2).');
     // URL, message and message type
     $this->class->setRedirect('index.php?option=com_foobar', 'Morning Universe', 'notice');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (3).');
     $this->assertAttributeEquals('Morning Universe', 'message', $this->class, 'Checks the message (3).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (3).');
     // With previously set message
     // URL
     $this->class->setMessage('Hi all');
     $this->class->setRedirect('index.php?option=com_foobar');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (4).');
     $this->assertAttributeEquals('Hi all', 'message', $this->class, 'Checks the message (4).');
     $this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type (4).');
     // URL and message
     $this->class->setMessage('Hi all');
     $this->class->setRedirect('index.php?option=com_foobar', 'Bye all');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (5).');
     $this->assertAttributeEquals('Bye all', 'message', $this->class, 'Checks the message (5).');
     $this->assertAttributeEquals('message', 'messageType', $this->class, 'Checks the message type (5).');
     // URL, message and message type
     $this->class->setMessage('Hi all');
     $this->class->setRedirect('index.php?option=com_foobar', 'Bye all', 'notice');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (6).');
     $this->assertAttributeEquals('Bye all', 'message', $this->class, 'Checks the message (6).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (6).');
     // URL and message type
     $this->class->setMessage('Hi all');
     $this->class->setRedirect('index.php?option=com_foobar', null, 'notice');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (7).');
     $this->assertAttributeEquals('Hi all', 'message', $this->class, 'Checks the message (7).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (7).');
     // With previously set message and message type
     // URL
     $this->class->setMessage('Hello folks', 'notice');
     $this->class->setRedirect('index.php?option=com_foobar');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (8).');
     $this->assertAttributeEquals('Hello folks', 'message', $this->class, 'Checks the message (8).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (8).');
     // URL and message
     $this->class->setMessage('Hello folks', 'notice');
     $this->class->setRedirect('index.php?option=com_foobar', 'Bye, Folks');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (9).');
     $this->assertAttributeEquals('Bye, Folks', 'message', $this->class, 'Checks the message (9).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (9).');
     // URL, message and message type
     $this->class->setMessage('Hello folks', 'notice');
     $this->class->setRedirect('index.php?option=com_foobar', 'Bye, folks', 'notice');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (10).');
     $this->assertAttributeEquals('Bye, folks', 'message', $this->class, 'Checks the message (10).');
     $this->assertAttributeEquals('notice', 'messageType', $this->class, 'Checks the message type (10).');
     // URL and message type
     $this->class->setMessage('Folks?', 'notice');
     $this->class->setRedirect('index.php?option=com_foobar', null, 'question');
     $this->assertAttributeEquals('index.php?option=com_foobar', 'redirect', $this->class, 'Checks the redirect (10).');
     $this->assertAttributeEquals('Folks?', 'message', $this->class, 'Checks the message (10).');
     $this->assertAttributeEquals('question', 'messageType', $this->class, 'Checks the message type (10).');
 }
Пример #8
0
 function attribPoints()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $login = JFactory::getApplication()->input->get('login', '', 'username');
     $coupon = JFactory::getApplication()->input->get('couponCode', '', 'string');
     $trackID = JFactory::getApplication()->input->get('trackID', '', 'string');
     $query = "SELECT id FROM #__alpha_userpoints_qrcodetrack WHERE `trackid`='" . $trackID . "'";
     $db->setQuery($query);
     $idTrack = $db->loadResult();
     $query = "SELECT id FROM #__users WHERE `username`='" . $login . "' AND `block`='0'";
     $db->setQuery($query);
     $userID = $db->loadResult();
     if ($userID) {
         // insert API AlphaUserPoint
         $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php';
         require_once $api_AUP;
         $referrerid = AlphaUserPointsHelper::getAnyUserReferreID($userID);
         $nullDate = $db->getNullDate();
         $date =& JFactory::getDate();
         $now = $date->toSql();
         $query = "SELECT * FROM #__alpha_userpoints_coupons WHERE `couponcode`='{$coupon}' AND (`expires`>='{$now}' OR `expires`='0000-00-00 00:00:00')";
         $db->setQuery($query);
         $result = $db->loadObjectList();
         if ($result) {
             $resultCouponExist = 0;
             // check if public or private coupon
             if (!$result[0]->public) {
                 // private -> usable once per one user
                 $query = "SELECT count(*) FROM #__alpha_userpoints_details WHERE `keyreference`='{$coupon}'";
                 $db->setQuery($query);
                 $resultCouponExist = $db->loadResult();
                 if (!$resultCouponExist) {
                     // insert points
                     AlphaUserPointsHelper::newpoints('sysplgaup_couponpointscodes', $referrerid, $result[0]->couponcode, $result[0]->description, $result[0]->points);
                     //if ( AlphaUserPointsHelper::newpoints( 'sysplgaup_couponpointscodes', $referrerid, $result[0]->couponcode, $result[0]->description, $result[0]->points, true )===true ){
                     // insert confirmed in track table
                     $this->updateTableQRTrack($idTrack);
                     return $result[0]->points;
                     //}
                 } else {
                     $msg = JText::_('AUP_THIS_COUPON_WAS_ALREADY_USED');
                     JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&view=registerqrcode&QRcode=' . $coupon . '&trackID=' . $trackID, $msg);
                     JControllerLegacy::redirect();
                 }
             } elseif ($result[0]->public) {
                 // public -> usable once per all users
                 $keyreference = $coupon . "##" . $userID;
                 $query = "SELECT count(*) FROM #__alpha_userpoints_details WHERE `keyreference`='{$keyreference}'";
                 $db->setQuery($query);
                 $resultCouponExist = $db->loadResult();
                 if (!$resultCouponExist) {
                     // insert points
                     AlphaUserPointsHelper::newpoints('sysplgaup_couponpointscodes', $referrerid, $keyreference, $result[0]->description, $result[0]->points);
                     //if ( AlphaUserPointsHelper::newpoints( 'sysplgaup_couponpointscodes', $referrerid, $keyreference, $result[0]->description, $result[0]->points, true )===true ){
                     // insert confirmed in track table
                     $this->updateTableQRTrack($idTrack);
                     return $result[0]->points;
                     //}
                 } else {
                     $msg = JText::_('AUP_THIS_COUPON_WAS_ALREADY_USED');
                     JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&view=registerqrcode&QRcode=' . $coupon . '&trackID=' . $trackID, $msg);
                     JControllerLegacy::redirect();
                 }
             }
         } else {
             $msg = JText::_('AUP_COUPON_NOT_AVAILABLE');
             JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&view=registerqrcode&QRcode=' . $coupon . '&trackID=' . $trackID, $msg);
             JControllerLegacy::redirect();
         }
     } else {
         // no username
         $msg = JText::_('ALERTNOTAUTH');
         JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&view=registerqrcode&QRcode=' . $coupon . '&trackID=' . $trackID, $msg);
         JControllerLegacy::redirect();
     }
 }
Пример #9
0
 public function checkout()
 {
     // set template and params
     if (!($this->template = $this->application->getTemplate())) {
         return $this->app->error->raiseError(500, JText::_('No template selected'));
     }
     $this->app->document->addScript('assets:js/formhandler.js');
     $step = $this->app->request->get('step', 'string', 'customer');
     $layout = 'checkout';
     $this->params = $this->application->getParams('site');
     // Initialize the Cash Register
     $CR = $this->app->cashregister->start();
     // Import Transfer Data
     if ($step != 'receipt') {
         $CR->import();
     }
     //Setup Page Variables
     $page = $CR->page;
     // $customer = $this->app->request->get('customer','array');
     // $CR->order->billing = $this->app->data->create($customer['billing']);
     // $CR->order->shipping = $this->app->data->create($customer['shipping']);
     switch ($step) {
         case 'customer':
             $page->title = 'Customer Information';
             $page->subtitle = 'Please enter your information below.';
             $page->id = $step;
             $page->inProgress = array($step);
             $page->addButton('print', '', 'Print', false)->addButton('back', '', 'Back', false)->addButton('proceed', 'payment', 'Proceed');
             break;
         case 'payment':
             $page->title = 'Payment Information';
             $page->subtitle = 'Please enter your payment information below.';
             $page->id = $step;
             $page->complete = array('customer');
             $page->inProgress = array($step);
             $page->addButton('print', '', '', false)->addButton('back', 'customer', 'Back')->addButton('proceed', 'confirm', 'Proceed');
             break;
         case 'confirm':
             $page->title = 'Order Confirmation';
             $page->subtitle = '<span class="uk-text-danger">Please make sure that your order is correct.</span>';
             $page->id = $step;
             $page->complete = array('customer', 'payment');
             $page->inProgress = array($step);
             $page->addButton('print', '', '', false)->addButton('back', 'payment', 'Back')->addButton('proceed', 'processPayment', 'Pay Now');
             break;
         case 'receipt':
             $page->title = 'Order Receipt';
             $page->subtitle = 'Thank you for your purchase.';
             $page->id = $step;
             $page->complete = array('customer', 'payment', 'confirm');
             $page->inProgress = array($step);
             $page->addButton('print', 'Print Receipt')->addButton('back', '', 'Back', false)->addButton('proceed', 'home', 'Return to Home Page');
             $this->app->document->addStyleSheet('assets:css/receipt.css');
             break;
         case 'home':
             JControllerLegacy::setRedirect('/');
             JControllerLegacy::Redirect();
             break;
         default:
             $page->title = 'Customer Information';
             $page->subtitle = 'Please enter your information below.';
             $page->id = 'customer';
             $page->inProgress = array('customer');
             $page->addButton('print', '', 'Print', false)->addButton('back', '', 'Back', false)->addButton('proceed', 'payment', 'Proceed');
     }
     $this->CashRegister = $CR;
     // display view
     $this->getView()->addTemplatePath($this->template->getPath())->setLayout($layout)->display();
 }
Пример #10
0
    /**
     * method to install the component
     *
     * @return void
     */
    function install($parent)
    {
        // includes
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'assets' . DS . 'includes' . DS . 'version.php';
        require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'assets' . DS . 'includes' . DS . 'functions.php';
        ?>
				<div class="well"><img src="<?php 
        echo JURI::base();
        ?>
components/com_alphauserpoints/assets/images/aup_logo.png" alt="" align="left" /><h1>&nbsp;AlphaUserPoints Installation <?php 
        echo _ALPHAUSERPOINTS_NUM_VERSION;
        ?>
</h1>
				<?php 
        $app = JFactory::getApplication();
        $error = 0;
        $cache = JFactory::getCache();
        $cache->clean(null, 'com_alphauserpoints');
        $db = JFactory::getDBO();
        jimport('joomla.filesystem.folder');
        jimport('joomla.filesystem.file');
        /************************************************************************
         *
         *                              START INSTALL
         *
         *************************************************************************/
        $install = "";
        // copy example of Joomla plugin for AlphaUserPoints
        $pathPluginsAUP = JPATH_SITE . DS . 'plugins' . DS . 'alphauserpoints';
        if (!JFolder::exists($pathPluginsAUP)) {
            JFolder::create($pathPluginsAUP);
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'install' . DS . 'plugins' . DS . 'example';
        $dest = $pathPluginsAUP . DS . 'example';
        JFolder::copy($src, $dest, '', true);
        // Disabled old module mod_aupadmin
        $query = "SELECT id FROM #__modules WHERE module='mod_aupadmin' AND published='1'";
        $db->setQuery($query);
        $idmodule = $db->LoadResult();
        if ($idmodule) {
            $query = "UPDATE #__modules SET published='0' WHERE `module`='mod_aupadmin'";
            $db->setQuery($query);
            $db->query();
        }
        // Install plugins
        $plugin_installer = new JInstaller();
        $file_origin = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'install' . DS . 'plugins' . DS . 'alphauserpointsicon';
        if ($plugin_installer->install($file_origin)) {
            // publish plugin
            $query = "UPDATE #__extensions SET enabled='1' WHERE `element`='alphauserpointsicon' AND `type`='plugin'";
            $db->setQuery($query);
            $db->query();
            $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle" /> Installing AlphaUserPoints Quick Icon <b>Button</b><br/>';
        } else {
            $error++;
        }
        $plugin_installer = new JInstaller();
        $file_origin = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'install' . DS . 'plugins' . DS . 'alphauserpoints';
        if ($plugin_installer->install($file_origin)) {
            // publish plugin
            $query = "UPDATE #__extensions SET enabled='1' WHERE `element`='alphauserpoints' AND `type`='plugin' AND folder='system'";
            $db->setQuery($query);
            $db->query();
            $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle" /> Installing AlphaUserPoints <b>System</b> Plugin <br/>';
        } else {
            $error++;
        }
        $plugin_installer = new JInstaller();
        $file_origin = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'install' . DS . 'plugins' . DS . 'sysplgaup_newregistered';
        if ($plugin_installer->install($file_origin)) {
            // publish plugin
            $query = "UPDATE #__extensions SET enabled='1', ordering='999' WHERE element='sysplgaup_newregistered' AND `type`='plugin' AND folder='user'";
            $db->setQuery($query);
            $db->query();
            $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle" /> Installing AlphaUserPoints Registering <b>User</b> Plugin <br/>';
        } else {
            $error++;
        }
        $plugin_installer = new JInstaller();
        $file_origin = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'install' . DS . 'plugins' . DS . 'sysplgaup_raffle';
        if ($plugin_installer->install($file_origin)) {
            // publish plugin
            $query = "UPDATE #__extensions SET enabled='1' WHERE element='sysplgaup_raffle' AND `type`='plugin' AND folder='content'";
            $db->setQuery($query);
            $db->query();
            $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle" /> Installing AlphaUserPoints Raffle <b>Content</b> Plugin <br/>';
        } else {
            $error++;
        }
        $plugin_installer = new JInstaller();
        $file_origin = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'install' . DS . 'plugins' . DS . 'sysplgaup_reader2author';
        if ($plugin_installer->install($file_origin)) {
            // publish plugin
            $query = "UPDATE #__extensions SET enabled='1' WHERE element='sysplgaup_reader2author' AND `type`='plugin' AND folder='content'";
            $db->setQuery($query);
            $db->query();
            $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt=""  align="absmiddle" /> Installing AlphaUserPoints Reader to Author <b>Content</b> Plugin <br/>';
        } else {
            $error++;
        }
        $plugin_installer = new JInstaller();
        $file_origin = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'install' . DS . 'plugins' . DS . 'sysplgaup_content';
        if ($plugin_installer->install($file_origin)) {
            // publish plugin
            $query = "UPDATE #__extensions SET enabled='1' WHERE element='sysplgaup_content' AND `type`='plugin' AND folder='content'";
            $db->setQuery($query);
            $db->query();
            $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle" /> Installing AlphaUserPoints system <b>Content</b> Plugin <br/>';
        } else {
            $error++;
        }
        $plugin_installer = new JInstaller();
        $file_origin = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'install' . DS . 'plugins' . DS . 'plg_editors-xtd_raffle';
        if ($plugin_installer->install($file_origin)) {
            // publish plugin
            $query = "UPDATE #__extensions SET enabled='1' WHERE element='raffle' AND `type`='plugin' AND folder='editors-xtd'";
            $db->setQuery($query);
            $db->query();
            $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle"/> Installing AlphaUserPoints Raffle Editor Button <b>Editor</b> Plugin <br/>';
        } else {
            $error++;
        }
        $plugin_installer = new JInstaller();
        $file_origin = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'install' . DS . 'plugins' . DS . 'notification_rank_medal';
        if ($plugin_installer->install($file_origin)) {
            // publish plugin
            $query = "UPDATE #__extensions SET enabled='1' WHERE `element`='notification_rank_medal' AND `type`='plugin' AND folder='alphauserpoints'";
            $db->setQuery($query);
            $db->query();
            $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle" /> Installing AlphaUserPoints <b>Notification on update rank and medal</b> Plugin <br/>';
        } else {
            $error++;
        }
        if ($error) {
            JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints', 'NOTICE: AlphaUserPoints plugins are not successfully installed. Make sure that the plugins directory is writeable');
            JControllerLegacy::redirect();
        } else {
            // Insert rules and Guest user on fresh install
            $query = "SELECT id FROM #__alpha_userpoints WHERE `userid`='0' AND `referreid`='GUEST'";
            $db->setQuery($query);
            $result = $db->loadResult();
            if (!$result) {
                // This GUEST user is used by AUP system, don't remove!
                $query = "INSERT INTO #__alpha_userpoints (`id`, `userid`, `referreid`, `points`, `max_points`, `last_update`, `referraluser`, `referrees`, `blocked`, `levelrank`) VALUES ('', '0', 'GUEST', '0', '0', '0000-00-00 00:00:00', '', '0', '0', '0');";
                $db->setQuery($query);
                $db->query();
            }
            $query = "SELECT count(*) FROM #__alpha_userpoints_rules";
            $db->setQuery($query);
            $result = $db->loadResult();
            if (!$result) {
                // Insert default rules on fresh install
                $query = "INSERT INTO #__alpha_userpoints_rules (`id`, `rule_name`, `rule_description`, `rule_plugin`, `plugin_function`, `access`, `component`, `calltask`, `taskid`, `points`, `points2`, `percentage`, `rule_expire`, `sections`, `categories`, `content_items`, `exclude_items`, `published`, `system`, `duplicate`, `blockcopy`, `autoapproved`, `fixedpoints`, `category`, `displaymsg`, `msg`, `method`, `notification`, `emailsubject`, `emailbody`, `emailformat`, `bcc2admin`, `type_expire_date`, `chain`,`linkup`, `displayactivity`) VALUES\r\n\t\t\t\t\t\t\t('', 'AUP_NEWUSER', 'AUP_NEWUSERDESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_newregistered', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 1, 1, 0, 1, 1, 1, 'us', '0', '', '1', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_INVITE', 'AUP_INVITE_A_USER', 'AUP_SYSTEM', 'sysplgaup_invite', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 1, 're', '1', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_INVITESUCCES', 'AUP_INVITE_A_USERSUCCESS', 'AUP_SYSTEM', 'sysplgaup_invitewithsuccess', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 1, 're', '0', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_READTOAUTHOR', 'AUP_READTOAUTHORDESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_reader2author', '0', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 1, 'ar', '1', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_REFERRALPOINTS', 'AUP_REFERRALPOINTSDESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_referralpoints', '1', '', '', '', 0, 0, 1, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 1, 'co', '0', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_BONUSPOINTS', 'AUP_BONUSPOINTSDESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_bonuspoints', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 1, 0, 1, 1, 'ot', '0', '', '4', '0', '', '', '0', '0', '0', '1', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_WINNERNOTIFICATION', 'AUP_WINNERNOTIFICATIONDESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_winnernotification', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 0, 'sy', '0', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_COUPON_POINTS_CODES', 'AUP_COUPON_POINTS_CODES_DESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_couponpointscodes', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 0, 'cd', '1', '', '1', '0', '', '', '0', '0', '0', '0', '0', '1'),\t\t\t\r\n\t\t\t\t\t\t\t('', 'AUP_RAFFLE', 'AUP_RAFFLE_DESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_raffle', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 0, 'ot', '1', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_CUSTOM', 'AUP_CUSTOM_DESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_custom', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 0, 1, 0, 'ot', '1', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_UPLOADAVATAR', 'AUP_UPLOADAVATAR_DESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_uploadavatar', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 1, 'us', '1', '', '1', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_PROFILECOMPLETE', 'AUP_PROFILECOMPLETE_DESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_profilecomplete', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 1, 'us', '1', '', '1', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_PROFILE_VIEW', 'AUP_PROFILE_VIEW_DESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_profile_view', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 1, 'co', '1', '', '1', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_CHANGE_LEVEL_1', 'AUP_CHANGE_LEVEL_DESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_changelevel1', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 1, 'us', '0', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_CHANGE_LEVEL_2', 'AUP_CHANGE_LEVEL_DESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_changelevel2', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 1, 'us', '0', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_CHANGE_LEVEL_3', 'AUP_CHANGE_LEVEL_DESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_changelevel3', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 1, 0, 1, 1, 1, 'us', '0', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\t\t\t\r\n\t\t\t\t\t\t\t('', 'AUP_COMBINED_ACTIVITIES', 'AUP_COMBINE_ACTIVITIES_DESCRIPTION', 'AUP_SYSTEM', 'sysplgaup_archive', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 1, 1, 0, 1, 1, 0, 'sy', '0', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_KU_NEW_TOPIC', 'AUP_KU_NEW_TOPIC_DESCRIPTION', 'AUP_KUNENA_FORUM', 'plgaup_kunena_topic_create', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 0, 0, 0, 1, 1, 'fo', '1', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_KU_REPLY_TOPIC', 'AUP_KU_REPLY_DESCRIPTION', 'AUP_KUNENA_FORUM', 'plgaup_kunena_topic_reply', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 0, 0, 0, 1, 1, 'fo', '1', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_KU_THANKYOU', 'AUP_KU_THANKYOU_DESCRIPTION', 'AUP_KUNENA_FORUM', 'plgaup_kunena_message_thankyou', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 0, 0, 0, 1, 1, 'fo', '1', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1'),\r\n\t\t\t\t\t\t\t('', 'AUP_KU_DELETE_POST', 'AUP_KU_DELETE_POST_DESCRIPTION', 'AUP_KUNENA_FORUM', 'plgaup_kunena_message_delete', '1', '', '', '', 0, 0, 0, '0000-00-00 00:00:00', '', '', '', '', 0, 0, 0, 0, 1, 1, 'fo', '1', '', '4', '0', '', '', '0', '0', '0', '0', '0', '1');";
                $db->setQuery($query);
                if ($db->query()) {
                    // default
                    $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle" /> 17 default rules installed<br/>';
                    // Kunena
                    $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle" /> 4 default rules for Kunena installed<br/>';
                }
                // Insert version on fresh install
                $query = "SELECT version FROM #__alpha_userpoints_version WHERE 1";
                $db->setQuery($query);
                $result = $db->loadResult();
                if (!$result) {
                    $query = "INSERT INTO #__alpha_userpoints_version (`version`) VALUES ('AUP190');";
                    $db->setQuery($query);
                    $db->query();
                }
                // fresh install or update -> update table version
                aup_update_db_version();
            }
            $query = "SELECT COUNT(*) FROM #__alpha_userpoints_levelrank";
            $db->setQuery($query);
            $nblevelrank = $db->loadResult();
            if (!$nblevelrank) {
                // insert sample ranks and medals on fresh install
                $query = "INSERT INTO `#__alpha_userpoints_levelrank` (`id`, `rank`, `description`, `levelpoints`, `typerank`, `icon`, `image`, `gid`, `category`) VALUES\r\n\t\t\t\t\t\t\t\t('', 'Gold member', 'Gold member', 10000, 0, 'icon_gold.gif', 'gold.gif', 0, 0),\r\n\t\t\t\t\t\t\t\t('', 'Silver member', 'Silver member', 6000, 0, 'icon_silver.gif', 'silver.gif', 0, 0),\r\n\t\t\t\t\t\t\t\t('', 'Bronze member', 'Bronze member', 3000, 0, 'icon_bronze.gif', 'bronze.gif', 0, 0),\t\t\t\r\n\t\t\t\t\t\t\t\t('', 'Honor Medal 2015', 'Honor Medal 2015 for best activities on this site', 1000, 1, 'award_star_gold.gif', 'award_big_gold.png', 0, 0);";
                $db->setQuery($query);
                $db->query();
                $install .= '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle" /> Sample ranks/medals installed<br/>';
            }
            // install default modules
            // =======================
            $status = new stdClass();
            $status->modules = array();
            $status->plugins = array();
            $src = $parent->getParent()->getPath('source');
            $manifest = $parent->getParent()->manifest;
            $modules = $manifest->xpath('modules/module');
            foreach ($modules as $module) {
                $name = (string) $module->attributes()->module;
                $client = (string) $module->attributes()->client;
                $modulePublished = (string) $module->attributes()->publish;
                $modulePosition = (string) $module->attributes()->position;
                if (is_null($client)) {
                    $client = 'site';
                }
                $path = $src . '/modules/' . $name;
                $installer = new JInstaller();
                $result = $installer->install($path);
                if ($client == 'administrator') {
                    //auto publish the admin modules
                    $sql = $db->getQuery(true)->update($db->qn('#__modules'))->set($db->qn('position') . ' = ' . $db->q($modulePosition))->where($db->qn('module') . ' = ' . $db->q($name));
                    if ($modulePublished) {
                        $sql->set($db->qn('published') . ' = ' . $db->q('1'));
                    }
                    $db->setQuery($sql);
                    $db->execute();
                    // Link to all pages
                    $query = $db->getQuery(true);
                    $query->select('id')->from($db->qn('#__modules'))->where($db->qn('module') . ' = ' . $db->q($name));
                    $db->setQuery($query);
                    $moduleid = $db->loadResult();
                    $query = $db->getQuery(true);
                    $query->select('*')->from($db->qn('#__modules_menu'))->where($db->qn('moduleid') . ' = ' . $db->q($moduleid));
                    $db->setQuery($query);
                    $assignments = $db->loadObjectList();
                    $isAssigned = !empty($assignments);
                    if (!$isAssigned) {
                        $o = (object) array('moduleid' => $moduleid, 'menuid' => 0);
                        $db->insertObject('#__modules_menu', $o);
                    }
                }
                $status->modules[] = array('name' => $name, 'client' => $client, 'result' => $result);
            }
            if (count($status->modules)) {
                foreach ($status->modules as $module) {
                    $install .= $module['result'] ? '<img src="components/com_alphauserpoints/assets/images/icon-16-allow.png" alt="" align="absmiddle" /> Module ' . $module['name'] . ' installed<br/>' : '<img src="components/com_alphauserpoints/assets/images/publish_x.png" alt="" align="absmiddle" /> Module ' . $module['name'] . ' not installed !!!<br/>';
                }
            }
            echo "<p>&nbsp;</p><p>&nbsp;</p><p>" . $install . "</p>";
            echo '<p>&nbsp;</p><p><a href="index.php?option=com_alphauserpoints" class="btn btn-primary">Go to AlphaUserPoints</a></p>';
            echo "<p>" . aup_CopySite('left') . "</p>";
            echo "<p></p>";
            echo "</div>";
        }
    }
 /**
  * Set a URL for browser redirection.
  * Use type 'error' if the message is an error message
  * @param   string  $url   URL to redirect to.
  * @param   string  $msg   Message to display on redirect. Optional, defaults to value set internally by controller, if any.
  * @param   string  $type  Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage.
  *
  * @return  JController  This object to support chaining.
  *
  * @since   11.1
  */
 public function setRedirect($url = null, $msg = null, $type = null)
 {
     if ($url === null) {
         $url = $this->redirectPath;
     }
     $format = JRequest::getWord('format');
     if ($format !== 'json') {
         // add menu item id in front
         if (JFactory::getApplication()->isSite()) {
             $url = jRoute::_($url, false);
         }
         return parent::setRedirect($url, $msg, $type);
     }
     if ($msg !== null) {
         // Controller may have set this directly
         $this->json->message = $msg;
     }
     // Ensure the type is not overwritten by a previous call to setMessage.
     if (empty($type)) {
         if (empty($this->messageType)) {
             $this->messageType = 'message';
         }
     } else {
         $this->messageType = $type;
     }
     if ($this->messageType == 'message') {
         $this->json->type = 'alert-info';
     } else {
         if ($this->messageType == 'error') {
             $this->json->type = 'alert-error';
         } else {
             $this->json->type = 'alert-' . $this->messageType;
         }
     }
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Cache-Control: no-cache, must-revalidate");
     header("Pragma: no-cache");
     header("Content-type: application/json;; charset=utf-8");
     echo json_encode($this->json);
     jexit();
 }
Пример #12
0
 function _make_raffle_now()
 {
     $app = JFactory::getApplication();
     require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php';
     $db = JFactory::getDBO();
     // Proceed raffle now
     $cid = JFactory::getApplication()->input->get('cid', array(0), 'array');
     $rowRaffle = $this->_edit_raffle();
     $rowRaffle = $rowRaffle[0];
     $jnow = JFactory::getDate();
     $now = $jnow->toSql();
     // add offset
     $config = JFactory::getConfig();
     $tzoffset = $config->get('config.offset');
     $datetimestamp = strtotime($now);
     $now = date('Y-m-d H:i:s', $datetimestamp + $tzoffset * 60 * 60);
     // get params definitions
     $params = JComponentHelper::getParams('com_alphauserpoints');
     // Raffle date is not today ?
     if ($rowRaffle->raffledate != '0000-00-00 00:00:00' && $now < $rowRaffle->raffledate) {
         echo "<script> alert('" . JText::_('AUP_DATE_OF_RAFFLE_IS_NOT_TODAY') . "'); window.history.go(-1); </script>\n";
         exit;
     }
     // load external plugins
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('alphauserpoints');
     $results = $dispatcher->trigger('onBeforeMakeRaffleAlphaUserPoints', array(&$rowRaffle, $now));
     $winner1 = 0;
     $winner2 = 0;
     $winner3 = 0;
     $winner1_Referreid = 0;
     $winner2_Referreid = 0;
     $winner3_Referreid = 0;
     // exclude users if rule enabled
     $queryExclude = " AND `published`='1'";
     // first raffle
     // select all users registered or only users with registration for this raffle
     if ($rowRaffle->inscription) {
         $query = "SELECT id, userid as uid FROM #__alpha_userpoints_raffle_inscriptions WHERE raffleid=" . $rowRaffle->id;
     } else {
         $query = "SELECT userid as uid FROM #__alpha_userpoints WHERE blocked='0'" . $queryExclude;
     }
     $db->setQuery($query);
     $listParticipants = $db->loadObjectList();
     if (!$listParticipants) {
         echo "<script> alert('" . JText::_('AUP_NO_PARTICIPANT') . "'); window.history.go(-1); </script>\n";
         exit;
     }
     $max = count($listParticipants) - 1;
     $choice = rand(0, $max);
     $winner1 = $listParticipants[$choice]->uid;
     if ($rowRaffle->numwinner > 1) {
         // 2th raffle without first winner
         if ($rowRaffle->inscription) {
             $query = "SELECT userid as uid FROM #__alpha_userpoints_raffle_inscriptions WHERE raffleid=" . $rowRaffle->id . " AND userid!='{$winner1}'";
         } else {
             $query = "SELECT userid as uid FROM #__alpha_userpoints WHERE blocked='0' AND userid!='{$winner1}'" . $queryExclude;
         }
         $db->setQuery($query);
         $listParticipants2 = $db->loadObjectList();
         $max2 = count($listParticipants2) - 1;
         $choice2 = rand(0, $max2);
         $winner2 = @$listParticipants2[$choice2]->uid;
     }
     if ($rowRaffle->numwinner == 3) {
         // 3th raffle without first and second winner
         if ($rowRaffle->inscription) {
             $query = "SELECT userid as uid FROM #__alpha_userpoints_raffle_inscriptions WHERE raffleid=" . $rowRaffle->id . " AND userid!='{$winner1}' AND userid!='{$winner2}'";
         } else {
             $query = "SELECT userid as uid FROM #__alpha_userpoints WHERE blocked='0' AND userid!='{$winner1}' AND userid!='{$winner2}'" . $queryExclude;
         }
         $db->setQuery($query);
         $listParticipants3 = $db->loadObjectList();
         $max3 = count($listParticipants3) - 1;
         $choice3 = rand(0, $max3);
         $winner3 = @$listParticipants3[$choice3]->uid;
     }
     // Save winner(s)
     $row = JTable::getInstance('raffle');
     $row->load($rowRaffle->id);
     $row->winner1 = $winner1;
     $row->winner2 = $winner2;
     $row->winner3 = $winner3;
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
     }
     // attribs points or coupon code
     if ($winner1) {
         $winner1_Referreid = AlphaUserPointsHelper::getAnyUserReferreID(intval($winner1));
     }
     if ($winner2) {
         $winner2_Referreid = AlphaUserPointsHelper::getAnyUserReferreID(intval($winner2));
     }
     if ($winner3) {
         $winner3_Referreid = AlphaUserPointsHelper::getAnyUserReferreID(intval($winner3));
     }
     switch ($rowRaffle->rafflesystem) {
         case '1':
             // is coupon code ...
             // send notification by email
             if ($rowRaffle->sendcouponbyemail) {
                 if ($winner1 && $rowRaffle->couponcodeid1) {
                     $this->sendnotification4couponcode($winner1_Referreid, $this->_get_Coupon($rowRaffle->couponcodeid1));
                 }
                 if ($winner2 && $rowRaffle->couponcodeid2) {
                     $this->sendnotification4couponcode($winner2_Referreid, $this->_get_Coupon($rowRaffle->couponcodeid2));
                 }
                 if ($winner3 && $rowRaffle->couponcodeid3) {
                     $this->sendnotification4couponcode($winner3_Referreid, $this->_get_Coupon($rowRaffle->couponcodeid3));
                 }
             }
             // uddeim notification
             if ($params->get('sendMsgUddeim', 0) && $params->get('fromIdUddeim')) {
                 // Uddeim notification integration
                 require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helpers' . DS . 'uddeim.api.php';
                 $SiteName = $app->getCfg('sitename');
                 if ($winner1 && $rowRaffle->couponcodeid1) {
                     $message = sprintf(JText::_('AUP_EMAILNOTIFICATION_MSG_COUPONCODE'), $SiteName, $this->_get_Coupon($rowRaffle->couponcodeid1));
                     uddeIMAPI::sendNewMessage(intval($params->get('fromIdUddeim')), intval($winner1), $message);
                     $message = "";
                 }
                 if ($winner2 && $rowRaffle->couponcodeid2) {
                     $message = sprintf(JText::_('AUP_EMAILNOTIFICATION_MSG_COUPONCODE'), $SiteName, $this->_get_Coupon($rowRaffle->couponcodeid2));
                     uddeIMAPI::sendNewMessage(intval($params->get('fromIdUddeim')), intval($winner2), $message);
                     $message = "";
                 }
                 if ($winner3 && $rowRaffle->couponcodeid3) {
                     $message = sprintf(JText::_('AUP_EMAILNOTIFICATION_MSG_COUPONCODE'), $SiteName, $this->_get_Coupon($rowRaffle->couponcodeid3));
                     uddeIMAPI::sendNewMessage(intval($params->get('fromIdUddeim')), intval($winner3), $message);
                     $message = "";
                 }
             }
             break;
         case '2':
             // e-mail with a download link as a price
             if ($winner1 && $rowRaffle->link2download1) {
                 $this->sendnotificationDownload($winner1_Referreid, $rowRaffle->link2download1);
             }
             if ($winner2 && $rowRaffle->link2download2) {
                 $this->sendnotificationDownload($winner2_Referreid, $rowRaffle->link2download2);
             }
             if ($winner3 && $rowRaffle->link2download3) {
                 $this->sendnotificationDownload($winner3_Referreid, $rowRaffle->link2download3);
             }
             break;
         case '3':
             // just simple e-mail
             if ($winner1) {
                 $this->sendSimpleEmail($winner1_Referreid, '1');
             }
             if ($winner2) {
                 $this->sendSimpleEmail($winner2_Referreid, '2');
             }
             if ($winner3) {
                 $this->sendSimpleEmail($winner3_Referreid, '3');
             }
             break;
         default:
             // is points ...
             if ($winner1) {
                 AlphaUserPointsHelper::newpoints('sysplgaup_raffle', $winner1_Referreid, '', $rowRaffle->description, $rowRaffle->pointstoearn1);
             }
             if ($winner2) {
                 AlphaUserPointsHelper::newpoints('sysplgaup_raffle', $winner2_Referreid, '', $rowRaffle->description, $rowRaffle->pointstoearn2);
             }
             if ($winner3) {
                 AlphaUserPointsHelper::newpoints('sysplgaup_raffle', $winner3_Referreid, '', $rowRaffle->description, $rowRaffle->pointstoearn3);
             }
     }
     // end switch
     $results = $dispatcher->trigger('onAfterMakeRaffleAlphaUserPoints', array(&$rowRaffle, $now));
     $redirecturl = "index.php?option=com_alphauserpoints&task=raffle";
     JControllerLegacy::setRedirect($redirecturl);
     JControllerLegacy::redirect();
 }
Пример #13
0
 function _customrulepoints($cids, $reason, $points)
 {
     $app = JFactory::getApplication();
     // initialize variables
     $db = JFactory::getDBO();
     $query = "SELECT `id` FROM #__alpha_userpoints_rules WHERE `plugin_function`='sysplgaup_custom'";
     $db->setQuery($query);
     $rule_id = $db->loadResult();
     JArrayHelper::toInteger($cids);
     if (count($cids)) {
         require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php';
         foreach ($cids as $cid) {
             $query = "SELECT referreid FROM #__alpha_userpoints WHERE id='" . $cid . "'";
             $db->setQuery($query);
             $referrerid = $db->loadResult();
             if ($referrerid) {
                 AlphaUserPointsHelper::userpoints('sysplgaup_custom', $referrerid, 0, '', $reason, $points);
                 $this->checkTotalAfterRecalculate($referrerid, $rule_id);
             }
         }
         $app->enqueueMessage(JText::_('AUP_RECALCULATION_MADE'));
     }
     $redirecturl = "index.php?option=com_alphauserpoints&task=statistics";
     JControllerLegacy::setRedirect($redirecturl);
     JControllerLegacy::redirect();
 }
Пример #14
0
 function _delete_user_all_activities()
 {
     $app = JFactory::getApplication();
     // initialize variables
     $db = JFactory::getDBO();
     $c2id = JFactory::getApplication()->input->get('c2id', '', 'string');
     $post = JRequest::get('post');
     //$msgType	= '';
     //JArrayHelper::toInteger($cid);
     // load external plugins
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('alphauserpoints');
     $results = $dispatcher->trigger('onBeforeDeleteAllUserActivitiesAlphaUserPoints', array($c2id));
     // c2id = referreid
     if ($c2id) {
         $msg = JText::_('AUP_SUCCESSFULLYDELETED');
         $query = "DELETE FROM #__alpha_userpoints_details" . "\n WHERE `referreid` = '" . $c2id . "'";
         $db->setQuery($query);
         if (!$db->query()) {
             JError::raiseError(500, $db->getErrorMsg());
             return false;
         }
         $results = $dispatcher->trigger('onAfterDeleteAllUserActivitiesAlphaUserPoints', array($c2id));
         // c2id = referreid
     }
     // recalculate for this user
     $this->checkNewTotal($c2id);
     $app->enqueueMessage($msg);
     $redirect = 'index.php?option=com_alphauserpoints&task=' . $post['redirect'];
     JControllerLegacy::setRedirect($redirect);
     JControllerLegacy::redirect();
 }
Пример #15
0
 function _delete_medaluser()
 {
     $app = JFactory::getApplication();
     // initialize variables
     $db = JFactory::getDBO();
     $cid = JFactory::getApplication()->input->get('cid', 0, 'int');
     $rid = JFactory::getApplication()->input->get('rid', 0, 'int');
     $msgType = '';
     if ($cid) {
         // remove user medals
         $query = "DELETE FROM #__alpha_userpoints_medals" . "\n WHERE `id`={$cid} AND rid={$rid}";
         $db->setQuery($query);
         $db->query();
         if (!$db->query()) {
             $msg = $db->getErrorMsg();
             $msgType = 'error';
         } else {
             $msg = JText::_('AUP_SUCCESSFULLYDELETED');
         }
     }
     JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&task=edituser&cid[]=' . $rid, $msg);
     JControllerLegacy::redirect();
 }
Пример #16
0
 function _save_levelrank($apply = 0)
 {
     $app = JFactory::getApplication();
     // initialize variables
     $db = JFactory::getDBO();
     $post = JRequest::get('post');
     $row = JTable::getInstance('levelrank');
     if (!$row->bind($post)) {
         echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     if (!$row->store()) {
         echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     $msg = JText::_('AUP_DETAILSSAVED');
     // launch recalculation for all users
     JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&task=recalculate', $msg);
     JControllerLegacy::redirect();
 }
Пример #17
0
 function _save_templateinvite($apply = 0)
 {
     $app = JFactory::getApplication();
     // initialize variables
     $db = JFactory::getDBO();
     //$post = $_POST;
     $post = JFactory::getApplication()->input->getArray(array());
     $row = JTable::getInstance('template_invite');
     $id = JFactory::getApplication()->input->get('id', 0, 'int');
     if (!$row->bind($post)) {
         echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     if (!$row->store()) {
         echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
         exit;
     }
     $msg = JText::_('AUP_TEMPLATESAVED');
     if (!$apply) {
         JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&task=templateinvite', $msg);
     } else {
         JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&task=edittemplateinvite&cid[]=' . $id, $msg);
     }
     JControllerLegacy::redirect();
 }
Пример #18
0
 function _copy_rule()
 {
     $app = JFactory::getApplication();
     // Initialize variables
     $db = JFactory::getDBO();
     $cid = JFactory::getApplication()->input->get('cid', array(), 'array');
     JArrayHelper::toInteger($cid);
     $item = null;
     $total = count($cid);
     $j = 0;
     for ($i = 0; $i < $total; $i++) {
         $row = JTable::getInstance('rules');
         // main query
         $query = 'SELECT * FROM #__alpha_userpoints_rules' . ' WHERE id = ' . (int) $cid[$i];
         $db->setQuery($query, 0, 1);
         $item = $db->loadObject();
         $unique = uniqid('', false);
         if ($item->blockcopy == '0') {
             // values loaded into array set for store
             $row->id = NULL;
             $row->rule_name = JText::_('AUP_COPYOF') . " " . JText::_($item->rule_name);
             $row->rule_description = "";
             $row->rule_plugin = $item->rule_plugin;
             $row->plugin_function = $item->plugin_function . '_' . $unique;
             $row->access = $item->access;
             $row->component = $item->component;
             $row->calltask = $item->calltask;
             $row->taskid = $item->taskid;
             $row->points = $item->points;
             $row->points2 = $item->points2;
             $row->percentage = $item->percentage;
             $row->rule_expire = $item->rule_expire;
             $row->sections = $item->sections;
             $row->categories = $item->categories;
             $row->content_items = $item->content_items;
             $row->exclude_items = $item->exclude_items;
             $row->published = 0;
             $row->system = 0;
             $row->duplicate = 1;
             $row->blockcopy = 0;
             $row->autoapproved = $item->autoapproved;
             $row->fixedpoints = 1;
             $row->category = $item->category;
             $row->displaymsg = $item->displaymsg;
             $row->msg = $item->msg;
             $row->method = $item->method;
             $row->notification = $item->notification;
             $row->emailsubject = $item->emailsubject;
             $row->emailbody = $item->emailbody;
             $row->emailformat = $item->emailformat;
             $row->bcc2admin = $item->bcc2admin;
             $row->type_expire_date = $item->type_expire_date;
             $row->chain = 0;
             $row->linkup = intval($item->linkup);
             if (!$row->store()) {
                 JError::raiseError(500, $row->getError());
                 return false;
             }
             $j++;
         }
     }
     $msg = JText::sprintf('AUP_XCOPYOFRULE', $j);
     JControllerLegacy::setRedirect('index.php?option=com_alphauserpoints&task=rules', $msg);
     JControllerLegacy::redirect();
 }