Example #1
3
 protected function prepareDisplay($preconfig)
 {
     if (JCck::getConfig_Param('debug', 0)) {
         jimport('joomla.error.profiler');
         $profiler = new JProfiler();
     }
     $app = JFactory::getApplication();
     $this->form = $this->get('Form');
     $this->option = $app->input->get('option', '');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     $option = $this->option;
     $params = new JRegistry();
     $view = $this->getName();
     $isNew = 1;
     $live = '';
     $lives = array();
     $variation = '';
     jimport('cck.base.form.form');
     include_once JPATH_LIBRARIES_CCK . '/base/form/form_inc.php';
     if (isset($config['id'])) {
         JFactory::getSession()->set('cck_hash_seblod_form', JApplication::getHash($id . '|' . $type->name . '|' . $config['id']));
     }
     $this->config =& $config;
     $this->data =& $data;
     $this->id =& $id;
     $this->isNew =& $isNew;
     $this->params =& $params;
     $this->stage =& $stage;
     $this->type =& $type;
     $title = isset($type->title) ? $type->title : '';
     $name = isset($type->name) ? $type->name : '';
     $this->addToolbar($title, $name);
 }
 /**
  * Get the available fields
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		protected
  * @param
  * @return 		array	an array of options
  * @since 		4.3
  */
 protected function getOptions()
 {
     // Get the template ID
     $jinput = JFactory::getApplication()->input;
     $session = JFactory::getSession();
     $sess_template_id = $session->get('com_csvi.select_template', 0);
     if ($sess_template_id !== 0) {
         $sess_template_id = unserialize($sess_template_id);
     }
     $template_id = $jinput->get('template_id', $sess_template_id, 'int');
     // Load the selected template
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/template.php';
     $template = new CsviTemplate();
     $template->load($template_id);
     // Load the available fields
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/availablefields.php';
     $availablefields_model = new CsviModelAvailablefields();
     $fields = $availablefields_model->getAvailableFields($template->get('operation', 'options'), $template->get('component', 'options'), 'array');
     if (!is_array($fields)) {
         $avfields = array();
     } else {
         $avfields = array();
         foreach ($fields as $field) {
             $avfields[$field] = $field;
         }
     }
     return array_merge(parent::getOptions(), $avfields);
 }
Example #3
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return	void
  * @since	1.6
  */
 protected function populateState($ordering = null, $direction = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     // Adjust the context to support modal layouts.
     if ($layout = JRequest::getVar('layout')) {
         $this->context .= '.' . $layout;
     }
     $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
     $this->setState('filter.search', $search);
     $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int');
     $this->setState('filter.access', $access);
     $authorId = $app->getUserStateFromRequest($this->context . '.filter.author_id', 'filter_author_id');
     $this->setState('filter.author_id', $authorId);
     $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
     $this->setState('filter.published', $published);
     $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
     $this->setState('filter.category_id', $categoryId);
     $level = $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level', 0, 'int');
     $this->setState('filter.level', $level);
     $language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
     $this->setState('filter.language', $language);
     // List state information.
     parent::populateState('a.title', 'asc');
 }
 function fetchMethodForm($uid, $step, $update = false)
 {
     global $task;
     switch ($step) {
         case 2:
             $lists = array();
             $lists['action'] = _taskLink($task, $uid, array('step' => $step + 1), false);
             return HTML_DMUploadMethod::linkFileForm($lists);
             break;
         case 3:
             $url = stripslashes(JRequest::getString('url', 'http://'));
             $err = DMUploadMethod::linkFileProcess($uid, $step, $url);
             if ($err['_error']) {
                 _returnTo($task, $err['_errmsg'], '', array("method" => 'link', "step" => $step - 1, "localfile" => '', "url" => DOCMAN_Utils::safeEncodeURL($url)));
             }
             $uploaded = DOCMAN_Utils::safeEncodeURL(_DM_DOCUMENT_LINK . $url);
             $catid = $update ? 0 : $uid;
             $docid = $update ? $uid : 0;
             $session = JFactory::getSession();
             $session->set('docman.dmfilename', _DM_DOCUMENT_LINK);
             $session->set('docman.document_url', $url);
             return fetchEditDocumentForm($docid, $uploaded, $catid);
             break;
         default:
             break;
     }
     return true;
 }
Example #5
0
 /**
  * Method to build an SQL query to load the list data.
  *
  * @return string  An SQL query
  */
 protected function populateState($ordering = null, $direction = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     // Adjust the context to support modal layouts.
     if ($layout = JRequest::getVar('layout')) {
         $this->context .= '.' . $layout;
     }
     $search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
     $this->setState('filter.search', $search);
     $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int');
     $this->setState('filter.access', $access);
     $artist = $app->getUserStateFromRequest($this->context . '.filter.artist', 'filter_artist');
     $this->setState('filter.artist', $artist);
     $album = $app->getUserStateFromRequest($this->context . '.filter.album', 'filter_album', '');
     $this->setState('filter.album', $album);
     $categoryId = $app->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id');
     $this->setState('filter.category_id', $categoryId);
     $userId = $app->getUserStateFromRequest($this->context . '.filter.user_id', 'filter_user_id');
     $this->setState('filter.user_id', $userId);
     $year = $app->getUserStateFromRequest($this->context . '.filter.year', 'filter_year', '');
     $this->setState('filter.year', $year);
     // Load the parameters.
     $params = $app->getParams();
     $this->setState('params', $params);
     // process show_noauth parameter
     if (!$params->get('show_noauth', 1)) {
         $this->setState('filter.access', true);
     } else {
         $this->setState('filter.access', false);
     }
     // List state information.
     parent::populateState('a.title', 'asc');
 }
Example #6
0
    function send_certificate()
    {
        $app = JFactory::getApplication();
        $params = $app->getParams();
        $moodle_url = $params->get('MOODLE_URL');
        $cert_id = JRequest::getVar('cert_id');
        $simple = JRequest::getVar('simple');
        $email = JRequest::getString('mailto', '', 'post');
        $sender = JRequest::getString('sender', '', 'post');
        $from = JRequest::getString('from', '', 'post');
        $user = JFactory::getUser();
        $username = $user->username;
        $subject_default = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_SUBJECT', $user->name);
        $subject = JRequest::getString('subject', $subject_default, 'post');
        if (!$subject) {
            $subject = $subject_default;
        }
        $mailer = JFactory::getMailer();
        $config = JFactory::getConfig();
        $sender = array($config->get('mailfrom'), $config->get('fromname'));
        $mailer->setSender($sender);
        $mailer->addRecipient($email);
        $body = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_BODY', $user->name);
        $mailer->setSubject($subject);
        $mailer->setBody($body);
        $session = JFactory::getSession();
        $token = md5($session->getId());
        $pdf = file_get_contents($moodle_url . '/auth/joomdle/' . $simple . 'certificate_view.php?id=' . $cert_id . '&certificate=1&action=review&username='******'&token=' . $token);
        $tmp_path = $config->get('tmp_path');
        $filename = 'certificate-' . $cert_id . '-' . $user->name . '.pdf';
        file_put_contents($tmp_path . '/' . $filename, $pdf);
        $mailer->addAttachment($tmp_path . '/' . $filename);
        $send = $mailer->Send();
        unlink($tmp_path . '/' . $filename);
        if ($send !== true) {
            JError::raiseNotice(500, JText::_('COM_JOOMDLE_EMAIL_NOT_SENT'));
        } else {
            ?>
<div style="padding: 10px;">
    <div style="text-align:right">
        <a href="javascript: void window.close()">
            <?php 
            echo JText::_('COM_JOOMDLE_CLOSE_WINDOW');
            ?>
 <?php 
            echo JHtml::_('image', 'mailto/close-x.png', NULL, NULL, true);
            ?>
</a>
    </div>

    <h2>
        <?php 
            echo JText::_('COM_JOOMDLE_EMAIL_SENT');
            ?>
    </h2>
</div>

<?php 
        }
    }
Example #7
0
 function getRows(&$params, $start = 0, $limit, $detail_filter)
 {
     $db = JFactory::getDBO();
     $session =& JFactory::getSession();
     if (!isset($limit)) {
         $limit = intval($params->get('limit', 5));
     }
     if (!isset($detail_filter)) {
         $detail_filter = $params->get('detail_filter', 'low');
     }
     $where = '';
     if ($detail_filter == 'low') {
         $where = 'and (r.task = "apply" or r.task = "save")';
     } elseif ($detail_filter == 'medium') {
         $where = 'and (r.task != "cancel" and r.task != "preview" and r.option != "com_cpanel")';
     }
     // get admin activity
     $query = 'select r.*, u.name, u.username, u.email,e.name as extension from #__rokadminaudit as r, #__users as u, #__extensions as e where r.user_id = u.id and e.element = r.option ' . $where . ' order by id desc limit ' . intval($limit);
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     // rows count
     $query = 'select count(*), r.*, u.name, u.username, u.email,e.name as extension from #__rokadminaudit as r, #__users as u, #__extensions as e where r.user_id = u.id and e.element = r.option ' . $where . ' order by id desc';
     $db->setQuery($query);
     $count = $db->loadResult();
     return array('rows' => $rows, 'count' => $count);
 }
Example #8
0
 function export()
 {
     $selectedMail = JRequest::getInt('filter_mail', 0);
     $selectedStatus = JRequest::getString('filter_status', '');
     $filters = array();
     if (!empty($selectedMail)) {
         $filters[] = 'a.mailid = ' . $selectedMail;
     }
     if (!empty($selectedStatus)) {
         if ($selectedStatus == 'bounce') {
             $filters[] = 'a.bounce > 0';
         } elseif ($selectedStatus == 'open') {
             $filters[] = 'a.open > 0';
         } elseif ($selectedStatus == 'notopen') {
             $filters[] = 'a.open < 1';
         } elseif ($selectedStatus == 'failed') {
             $filters[] = 'a.fail > 0';
         }
     }
     $query = 'SELECT `subid` FROM `#__acymailing_userstats` as a ';
     if (!empty($filters)) {
         $query .= ' WHERE (' . implode(') AND (', $filters) . ')';
     }
     $currentSession =& JFactory::getSession();
     $currentSession->set('acyexportquery', $query);
     $this->setRedirect(acymailing_completeLink('data&task=export&sessionquery=1', false, true));
 }
Example #9
0
 function saveRemark()
 {
     $db = JFactory::getDBO();
     $post = JRequest::get('post');
     ## Getting the global DB session
     $session = JFactory::getSession();
     ## Gettig the orderid if there is one.
     $ordercode = $session->get('ordercode');
     if ($ordercode != $this->ordercode) {
         $msg = '<font color="#FF0000">' . JText::_('COM_TICKETMASTER_SAVING_CONTENT_FAILED') . '</font>';
         ### Odercodes are not the same
         $arr = array('status' => '666', 'msg' => $msg);
         echo json_encode($arr);
     } else {
         $model = $this->getModel('cart');
         ## Making the query for showing all the cars in list function
         $sql = 'SELECT id FROM #__ticketmaster_remarks WHERE ordercode = "' . $ordercode . '"';
         $db->setQuery($sql);
         $remarks = $db->loadObject();
         if ($remarks->id != 0) {
             $post['id'] = $remarks->id;
         }
         $post['remarks'] = $new_string = filter_var($this->remark, FILTER_SANITIZE_STRING);
         $post['ordercode'] = $ordercode;
         if (!$model->storeRemark($post)) {
             $msg = '<font color="#FF0000">' . JText::_('COM_TICKETMASTER_SAVING_CONTENT_FAILED') . '</font>';
             ### Odercodes are not the same
             $arr = array('status' => '666', 'msg' => $msg);
             echo json_encode($arr);
         } else {
             $arr = array('status' => '200', 'msg' => JText::_('COM_TICKETMASTER_CONTENT_SAVED'));
             echo json_encode($arr);
         }
     }
 }
Example #10
0
 public function onUserAfterSave($user, $isnew, $success, $msg)
 {
     $guruses = JFactory::getSession();
     $guru_data = $guruses->get("guru_data", "");
     $guru_action = $guruses->get("guru_action", "0");
     $option = JRequest::getVar("option", "");
     $view = JRequest::getVar("view", "");
     $task = JRequest::getVar("task", "");
     if ($guru_action == "1" && $option == "com_community" && $view == "register" && $task == "registerUpdateProfile") {
         $db = JFactory::getDbo();
         $data = json_decode($guru_data, true);
         $userpassword = $this->encriptPassword($data['password']);
         if ($data["guru_teacher"] == 1) {
             $sql = "insert into #__guru_customer(`id`, `company`, `firstname`, `lastname`) values (" . intval($user['id']) . ", '" . addslashes(trim($data['company'])) . "', '" . addslashes(trim($data['firstname'])) . "', '" . addslashes(trim($data['lastname'])) . "')";
         } elseif ($data["guru_teacher"] == 2) {
             $data["full_bio"] = JRequest::getVar("full_bio", "", "post", "string", JREQUEST_ALLOWRAW);
             $sql = "INSERT INTO `#__guru_authors` (`userid`, `gid`, `full_bio`, `images`, `emaillink`, `website`, `blog`, `facebook`, `twitter`, `show_email`, `show_website`, `show_blog`, `show_facebook`, `show_twitter`, `author_title`, `ordering`, `forum_kunena_generated`) VALUES('" . intval($user['id']) . "', 2, '" . $data["full_bio"] . "', '" . $data["images"] . "', '" . $data["emaillink"] . "', '" . $data["website"] . "', '" . $data["blog"] . "', '" . $data["facebook"] . "','" . $data["twitter"] . "', '" . $data["show_email"] . "', '" . $data["show_website"] . "', '" . $data["show_blog"] . "', '" . $data["show_facebook"] . "', '" . $data["show_twitter"] . "',  '" . $data["author_title"] . "', '" . $data["ordering"] . "', '')";
         }
         $db->setQuery($sql);
         $db->query();
         $sql = "delete from  #__community_users where userid = 0";
         $db->setQuery($sql);
         $db->query();
         $sql = "update #__users set password ='******' where id =" . intval($user['id']);
         $db->setQuery($sql);
         $db->query();
         $guruses->set("guru_data", "");
         $guruses->set("guru_action", "0");
     }
 }
Example #11
0
 function CaptchaSecurityImages($width = '120', $height = '40', $characters = '6')
 {
     $code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.75;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 20, 40, 100);
     $noise_color = imagecolorallocate($image, 100, 120, 180);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     /* generate random lines in background */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
     }
     /* create textbox and add text */
     $thispath = dirname(__FILE__) . '/';
     $textbox = imagettfbbox($font_size, 0, $thispath . $this->font, $code) or die('Error in imagettfbbox function');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, $font_size, 0, $x, $y, $text_color, $thispath . $this->font, $code) or die('Error in imagettftext function');
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     $session = JFactory::getSession();
     $session->set('security_code', $code);
 }
Example #12
0
 protected function getOptions()
 {
     $session = JFactory::getSession();
     $attr = '';
     // Initialize some field attributes.
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     // To avoid user's confusion, readonly="true" should imply disabled="true".
     if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
         $attr .= ' disabled="disabled"';
     }
     //
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->multiple ? ' multiple="multiple"' : '';
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     $db = JFactory::getDBO();
     $db->setQuery("SELECT t.name AS name, t.id AS id FROM #__k2_tags AS t WHERE published = 1 ORDER BY t.name ASC");
     $results = $db->loadObjectList();
     $tags = array();
     if (count($results)) {
         foreach ($results as $tag) {
             $tags[] = JHtml::_('select.option', $tag->id, $tag->name);
         }
         $tags = array_merge(parent::getOptions(), $tags);
         return $tags;
     } else {
         $tags = array();
         return $tags;
     }
 }
 /**
  * Return memcached connection object
  *
  * @return  object   memcached connection object
  *
  * @since   12.1
  */
 protected function getConnection()
 {
     if ((extension_loaded('memcached') && class_exists('Memcached')) != true) {
         return false;
     }
     $config = JFactory::getConfig();
     $this->_persistent = $config->get('memcache_persist', true);
     $this->_compress = $config->get('memcache_compress', false) == false ? 0 : Memcached::OPT_COMPRESSION;
     /*
      * This will be an array of loveliness
      * @todo: multiple servers
      * $servers	= (isset($params['servers'])) ? $params['servers'] : array();
      */
     $server = array();
     $server['host'] = $config->get('memcache_server_host', 'localhost');
     $server['port'] = $config->get('memcache_server_port', 11211);
     // Create the memcache connection
     if ($this->_persistent) {
         $session = JFactory::getSession();
         self::$_db = new Memcached($session->getId());
     } else {
         self::$_db = new Memcached();
     }
     $memcachedtest = self::$_db->addServer($server['host'], $server['port']);
     if ($memcachedtest == false) {
         return JError::raiseError(404, "Could not connect to memcached server");
     }
     self::$_db->setOption(Memcached::OPT_COMPRESSION, $this->_compress);
     // Memcached has no list keys, we do our own accounting, initialise key index
     if (self::$_db->get($this->_hash . '-index') === false) {
         $empty = array();
         self::$_db->set($this->_hash . '-index', $empty, 0);
     }
     return;
 }
Example #14
0
 function display($tpl = null)
 {
     global $mainframe;
     $style = $mainframe->getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word');
     $listStyle = "\n\t\t\t<ul id=\"submenu\">\n\t\t\t\t<li><a id=\"thumbs\" onclick=\"MediaManager.setViewType('thumbs')\">" . JText::_('Thumbnail View') . "</a></li>\n\t\t\t\t<li><a id=\"details\" onclick=\"MediaManager.setViewType('details')\">" . JText::_('Detail View') . "</a></li>\n\t\t\t</ul>\n\t\t";
     $document =& JFactory::getDocument();
     $document->setBuffer($listStyle, 'module', 'submenu');
     JHTML::_('behavior.mootools');
     $document->addScript('components/com_media/assets/mediamanager.js');
     $document->addStyleSheet('components/com_media/assets/mediamanager.css');
     JHTML::_('behavior.modal');
     $document->addScriptDeclaration("\n\t\twindow.addEvent('domready', function() {\n\t\t\tdocument.preview = SqueezeBox;\n\t\t});");
     JHTML::script('mootree.js');
     JHTML::stylesheet('mootree.css');
     JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ MediaManager.refreshFrame(); }'));
     $base = str_replace("\\", "/", JPATH_ROOT);
     $js = "\n\t\t\tvar basepath = '" . $base . '/images' . "';\n\t\t\tvar viewstyle = '" . $style . "';\n\t\t";
     $document->addScriptDeclaration($js);
     /*
      * Display form for FTP credentials?
      * Don't set them here, as there are other functions called before this one if there is any file write operation
      */
     jimport('joomla.client.helper');
     $ftp = !JClientHelper::hasCredentials('ftp');
     $this->assignRef('session', JFactory::getSession());
     $this->assignRef('config', JComponentHelper::getParams('com_media'));
     $this->assignRef('state', $this->get('state'));
     $this->assign('require_ftp', $ftp);
     $this->assign('folders_id', ' id="media-tree"');
     $this->assign('folders', $this->get('folderTree'));
     // Set the toolbar
     $this->_setToolBar();
     parent::display($tpl);
     echo JHTML::_('behavior.keepalive');
 }
Example #15
0
 /**
  * Method to get the field options.
  *
  * @return	array	The field option objects.
  * @since	1.6
  */
 protected function getOptions()
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     // Detect the native language.
     $native = JLanguageHelper::detectLanguage();
     if (empty($native)) {
         $native = 'en-GB';
     }
     // Get a forced language if it exists.
     $forced = $app->getLocalise();
     if (!empty($forced['language'])) {
         $native = $forced['language'];
     }
     // If a language is already set in the session, use this instead
     $session = JFactory::getSession()->get('setup.options', array());
     if (!empty($session['language'])) {
         $native = $session['language'];
     }
     // Get the list of available languages.
     $options = JLanguageHelper::createLanguageList($native);
     if (!$options || $options instanceof Exception) {
         $options = array();
     } else {
         usort($options, array($this, '_sortLanguages'));
     }
     // Set the default value from the native language.
     $this->value = $native;
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Example #16
0
 /**
  * Returns a set of parameters used to determine the applicable tax amount
  *
  * @return  array
  */
 public function getTaxDefiningParameters()
 {
     $result = array('country' => 'XX', 'state' => '', 'city' => '', 'vies' => 0);
     // Get country from GeoIP
     $result['country'] = $this->getCountryFromGeoIP();
     // Get information from Akeeba Subscriptions user record
     $user = JFactory::getUser();
     if (!$user->guest && $user->id) {
         $userModel = F0FModel::getTmpInstance('Users', 'AkeebasubsModel');
         $userparams = $userModel->user_id($user->id)->getMergedData($user->id);
         if ($userparams->country) {
             $result['country'] = $userparams->country;
         }
         if ($userparams->state) {
             $result['state'] = $userparams->state;
         }
         if ($userparams->viesregistered && $userparams->isbusiness) {
             $result['vies'] = 1;
         }
     }
     // Get information from the VAT dropdown module
     $session = JFactory::getSession();
     $moduleCountry = $session->get('country', null, 'mod_aktaxcountry');
     if (!empty($moduleCountry)) {
         $result['country'] = $moduleCountry;
     }
     return $result;
 }
Example #17
0
 function loadCurrencyValue()
 {
     $session = JFactory::getSession();
     $id_currency_session = $session->get('js_id_currency');
     $id_currency = JRequest::getInt('id_currency');
     $main_currency = $this->mainCurrency;
     if ($this->default_frontend_currency) {
         $main_currency = $this->default_frontend_currency;
     }
     if ($session->get('js_id_currency_orig') && $session->get('js_id_currency_orig') != $main_currency) {
         $id_currency_session = 0;
         $session->set('js_update_all_price', 1);
     }
     if (!$id_currency && $id_currency_session) {
         $id_currency = $id_currency_session;
     }
     $session->set('js_id_currency_orig', $main_currency);
     if ($id_currency) {
         $this->cur_currency = $id_currency;
     } else {
         $this->cur_currency = $main_currency;
     }
     $session->set('js_id_currency', $this->cur_currency);
     $all_currency = JSFactory::getAllCurrency();
     $current_currency = $all_currency[$this->cur_currency];
     if (!$current_currency->currency_value) {
         $current_currency->currency_value = 1;
     }
     $this->currency_value = $current_currency->currency_value;
     $this->currency_code = $current_currency->currency_code;
     $this->currency_code_iso = $current_currency->currency_code_iso;
 }
 /** this function returns math expression into your form, the parameter is optional
  * quite simmilar to insertQuestion, but returns the output as a text instead of echoing
  */
 public static function returnQuestion($attributes = array(), $suffix = '')
 {
     //default prime is 37, you can change it when specifying the different parameter
     $a = rand() % 10;
     // generates the random number
     $b = rand() % 10;
     // generates the random number
     $code = $a + $b;
     if (!is_array($attributes)) {
         $attributes = array();
     }
     if (!isset($attributes['name'])) {
         $suffix = $suffix . rand(1, 99999);
         $attributes['name'] = 'captcha_code' . $suffix;
     }
     if (!isset($attributes['id'])) {
         $attributes['id'] = $attributes['name'];
     }
     if (!isset($attributes['size'])) {
         $attributes['size'] = '2';
     }
     if (!isset($attributes['class'])) {
         $attributes['class'] = 'inputbox mathguard-answer required';
     }
     $session =& JFactory::getSession();
     $session->set($attributes['name'], $code);
     return $a . ' + ' . $b . ' = ' . '<input type="text" ' . JArrayHelper::toString($attributes) . ' />';
 }
Example #19
0
 /**
  * Method to auto-populate the model state.
  * Note. Calling getState in this method will result in recursion.
  *
  * @param string $ordering - name of column
  * @param string $direction - direction
  *
  * @return void
  * @since  1.0
  */
 protected function populateState($ordering = null, $direction = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     // Adjust the context to support modal layouts.
     if ($layout = JRequest::getVar('layout')) {
         $this->context .= '.' . $layout;
     }
     $form = JRequest::getVar('form');
     $name = $this->getName();
     if ($form != $name) {
         $search = $app->getUserState($this->context . '.filter.search');
         $published = $app->getUserState($this->context . '.filter.published');
         $published = $published ? $published : '';
     } else {
         $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
         if ($search == "Search...") {
             $search = "";
         }
         $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
     }
     $this->setState('filter.published', $published);
     $this->setState('filter.search', $search);
     // List state information.
     parent::populateState('a.automailing_name', 'asc');
 }
Example #20
0
 /**
  * Generates a message in html.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function toHTML()
 {
     $output = '';
     $session = JFactory::getSession();
     $messages = $session->get('messages', array(), SOCIAL_SESSION_NAMESPACE);
     // clear it from the session.
     $session->clear('messages', SOCIAL_SESSION_NAMESPACE);
     // If there's nothing stored in the session, ignore this.
     if (!$messages) {
         return;
     }
     foreach ($messages as $message) {
         $data = unserialize($message);
         if (!is_object($data)) {
             $obj = new stdClass();
             $obj->message = $data;
             $obj->type = 'info';
             $data = $obj;
         }
         $theme = FD::themes();
         $theme->set('content', $data->message);
         $theme->set('class', $data->type);
         $output .= $theme->output('site/info/default');
     }
     return $output;
 }
Example #21
0
 function display($tpl = null)
 {
     global $mainframe, $Itemid;
     $session =& JFactory::getSession();
     $package = $session->get('yrm_arr_package');
     $return_url = $session->get('yrm_return_url');
     $show = JRequest::getVar('show');
     $model = $this->getModel('package');
     if ($package && !$show) {
         $data = $model->getPackages1($package);
     }
     if ($this->getLayout() == 'checkout') {
         $packageid = JRequest::getInt('packageid');
         $package = $model->getPackage($packageid);
         $payment = $model->getPaymentMethods($packageid);
         $this->assign('package', $package);
         $this->assign('payment', $payment);
         $this->assign('return_url', $return_url);
         $this->assign('return_url', $return_url);
         parent::display($tpl);
         return;
     }
     $data = $model->getPackages();
     $this->assign('data', $data);
     $this->assign('package', $package);
     $this->assign('return_url', $return_url);
     $this->assign('show', $show);
     $this->assign('Itemid', $Itemid);
     parent::display($tpl);
 }
Example #22
0
 /**
  * Collect all data to show on the template
  *
  * @author RolandD, Max Milbers
  */
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $session = JFactory::getSession();
     parent::display($tpl);
 }
 function fetchMethodForm($uid, $step, $update)
 {
     global $task;
     switch ($step) {
         case 2:
             $lists = array();
             $lists['action'] = _taskLink($task, $uid, array('step' => $step + 1), false);
             return HTML_DMUploadMethod::uploadFileForm($lists);
             break;
         case 3:
             //upload file
             $file = JRequest::getVar('upload', array(), 'files', 'array');
             $err = DMUploadMethod::uploadFileProcess($uid, $step, $file);
             if ($err['_error']) {
                 _returnTo($task, $err['_errmsg'], '', array('step' => $step - 1, 'method' => 'http'));
             }
             $catid = $update ? 0 : $uid;
             $docid = $update ? $uid : 0;
             $session = JFactory::getSession();
             $session->set('docman.dmfilename', $file->name);
             $session->set('docman.document_url', null);
             return fetchEditDocumentForm($docid, $file->name, $catid);
             break;
         default:
             break;
     }
     return true;
 }
 public function importData()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // check if import is allowed for this user.
     $user = JFactory::getUser();
     if ($user->authorise('help_document.import', 'com_costbenefitprojection') && $user->authorise('core.import', 'com_costbenefitprojection')) {
         // Get the import model
         $model = $this->getModel('Help_documents');
         // get the headers to import
         $headers = $model->getExImPortHeaders();
         if (CostbenefitprojectionHelper::checkObject($headers)) {
             // Load headers to session.
             $session = JFactory::getSession();
             $headers = json_encode($headers);
             $session->set('help_document_VDM_IMPORTHEADERS', $headers);
             $session->set('backto_VDM_IMPORT', 'help_documents');
             $session->set('dataType_VDM_IMPORTINTO', 'help_document');
             // Redirect to import view.
             $message = JText::_('COM_COSTBENEFITPROJECTION_IMPORT_SELECT_FILE_FOR_HELP_DOCUMENTS');
             $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=import', false), $message);
             return;
         }
     }
     // Redirect to the list screen with error.
     $message = JText::_('COM_COSTBENEFITPROJECTION_IMPORT_FAILED');
     $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=help_documents', false), $message, 'error');
     return;
 }
Example #25
0
 protected function populateState($ordering = null, $direction = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $jinput = new Jinput();
     // Adjust the context to support modal layouts.
     if ($layout = $jinput->get('layout')) {
         $this->context .= '.' . $layout;
     }
     $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
     $this->setState('filter.search', $search);
     $trigger = $this->getUserStateFromRequest($this->context . '.filter.trigger', 'filter_trigger');
     $this->setState('filter.trigger', $trigger);
     $socialtype = $this->getUserStateFromRequest($this->context . '.filter.socialtype', 'filter_socialtype');
     $this->setState('filter.socialtype', $socialtype);
     $socialpost = $this->getUserStateFromRequest($this->context . '.filter.socialpost', 'filter_socialpost');
     $this->setState('filter.socialpost', $socialpost);
     $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
     $this->setState('filter.published', $published);
     $language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
     $this->setState('filter.language', $language);
     // List state information.
     parent::populateState('m.id', 'asc');
 }
Example #26
0
 /**
  * save function
  *
  * @return      nothing
  */
 public function save()
 {
     //$ids	= JRequest::getVar('cid', array(), '', 'array');
     // Get posted form variables.
     $task = $this->getTask();
     $data = JRequest::getVar('jform', array(), 'post', 'array');
     //echo "ECHO:: ".$data['id'];
     //  echo " task:: ".$task;
     $session =& JFactory::getSession();
     $articleid = $session->get('articleid');
     $fieldsattachid = $session->get('fieldsattachid');
     $model = $this->getModel();
     if (!$model->store()) {
         return JError::raiseWarning(500, $model->getError());
     }
     if ($task == "apply") {
         $msg = "";
         $lastid = $data['id'];
         if (empty($lastid)) {
             $lastid = $model->lastid;
         }
         $link = 'index.php?option=com_fieldsattach&view=fieldsattachimage&layout=edit&id=' . $lastid . '&tmpl=component&fieldsattachid=' . $fieldsattachid . '&reload=true';
         $this->setRedirect($link, $msg);
     }
     if ($task == "save") {
         $msg = "";
         //$link= 'index.php?option=com_fieldsattach&view=fieldsattachimages&tmpl=component&articleid='.$articleid.'&fieldsattachid='.$fieldsattachid.'&reset=1'  ;
         $link = 'index.php?option=com_fieldsattach&view=fieldsattachimages&tmpl=component&fieldsattachid=' . $fieldsattachid;
         $this->setRedirect($link, $msg);
     }
 }
Example #27
0
 /**
  * Method to add a user to a group.
  *
  * @param   integer  $userId   The id of the user.
  * @param   integer  $groupId  The id of the group.
  *
  * @return  boolean  True on success
  *
  * @since   11.1
  * @throws  RuntimeException
  */
 public static function addUserToGroup($userId, $groupId)
 {
     // Get the user object.
     $user = new JUser((int) $userId);
     // Add the user to the group if necessary.
     if (!in_array($groupId, $user->groups)) {
         // Get the title of the group.
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select($db->quoteName('title'))->from($db->quoteName('#__usergroups'))->where($db->quoteName('id') . ' = ' . (int) $groupId);
         $db->setQuery($query);
         $title = $db->loadResult();
         // If the group does not exist, return an exception.
         if (!$title) {
             throw new RuntimeException('Access Usergroup Invalid');
         }
         // Add the group data to the user object.
         $user->groups[$title] = $groupId;
         // Store the user object.
         $user->save();
     }
     // Set the group data for any preloaded user objects.
     $temp = JUser::getInstance((int) $userId);
     $temp->groups = $user->groups;
     if (JFactory::getSession()->getId()) {
         // Set the group data for the user object in the session.
         $temp = JFactory::getUser();
         if ($temp->id == $userId) {
             $temp->groups = $user->groups;
         }
     }
     return true;
 }
Example #28
0
 protected function getOptions()
 {
     // Initialize variables.
     $session = JFactory::getSession();
     $attr = '';
     // Initialize some field attributes.
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     // To avoid user's confusion, readonly="true" should imply disabled="true".
     if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
         $attr .= ' disabled="disabled"';
     }
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->multiple ? ' multiple="multiple"' : '';
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     $db = JFactory::getDBO();
     // generating query
     $db->setQuery("SELECT c.title AS name, c.id AS id, c.parent_id AS parent FROM #__categories AS c WHERE published = 1 AND extension = 'com_solidres' ORDER BY c.title, c.parent_id ASC");
     // getting results
     $results = $db->loadObjectList();
     if (count($results)) {
         // iterating
         $temp_options = array();
         foreach ($results as $item) {
             array_push($temp_options, array($item->id, $item->name, $item->parent));
         }
         foreach ($temp_options as $option) {
             if ($option[2] == 1) {
                 $this->options[] = JHtml::_('select.option', $option[0], $option[1]);
                 $this->recursive_options($temp_options, 1, $option[0]);
             }
         }
     }
 }
Example #29
0
 /**
  * getOTRSUserData
  *
  * Return the OTRS User ID for the currently active user
  * Retruns null if unable to lookup the user, or this is the anon user
  */
 function getOTRSUserData()
 {
     $user =& JFactory::getUser();
     if (!$user || $user->get('guest')) {
         return null;
     }
     $session = JFactory::getSession();
     if ($session->has('user', 'otrsgateway')) {
         return array($session->get('user', '', 'otrsgateway'), $session->get('customerIDs', array(), 'otrsgateway'));
     }
     $params =& JComponentHelper::getParams('com_otrsgateway');
     $vars = null;
     if ($params->get('otrsgateway_auth_map') == 0) {
         $vars = array('UserLogin' => array($user->get('username'), XSD_STRING));
     } else {
         if ($params->get('otrsgateway_auth_map') == 1) {
             $vars = array('UserEmail' => array($user->get('email'), XSD_STRING));
         } else {
             return null;
         }
     }
     $result = null;
     $gateway = new OTRSGatewayRPCHelper();
     if ($err = $gateway->callOTRS('JoomlaGatewayObject', 'GetCustomerUserData', $vars, $result)) {
         // Failed to find anything
         return null;
     } else {
         if (is_array($result) && count($result) > 1) {
             $session->set('user', $result[0], 'otrsgateway');
             $session->set('customerIDs', $result[1], 'otrsgateway');
             return $result;
         }
     }
     return null;
 }
Example #30
-1
 protected function populateState($ordering = null, $direction = null)
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     $session = JFactory::getSession();
     $jinput = new Jinput();
     // Adjust the context to support modal layouts.
     if ($layout = $jinput->get('layout')) {
         $this->context .= '.' . $layout;
     }
     $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
     $this->setState('filter.search', $search);
     $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published');
     $this->setState('filter.published', $published);
     $fieldtype = $this->getUserStateFromRequest($this->context . '.filter.fieldtype', 'filter_fieldtype', '');
     $this->setState('filter.fieldtype', $fieldtype);
     $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int');
     $this->setState('filter.access', $access);
     $level = $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level', 0, 'int');
     $this->setState('filter.level', $level);
     $language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
     $this->setState('filter.language', $language);
     // List state information.
     parent::populateState('u.ordering', 'asc');
 }