Ejemplo n.º 1
1
	function onBeforeDisplayContent( &$article, &$params, $limitstart ){
		//this may fire fron a component other than com_content
		
		if(!file_exists(JPATH_SITE.DS.'plugins'.DS.'system'.DS.'myApiConnectFacebook.php') || ( !array_key_exists('category',$article) && !array_key_exists('showK2Plugins',$params)  )){ return; }
		
		if((@$article->id != '') && (@$_POST['fb_sig_api_key'] == '') && class_exists('plgSystemmyApiOpenGraph')){
			$row = & JTable::getInstance('content');
			$row->load($article->id);
			$attribs = new JParameter($row->attribs);
			if($attribs->get('ogimage','') == ''){
				$attribs->set('ogimage',plgContentmyApiOpenGraphContent::getContentImage($article->text));
				$row->attribs = $attribs->toString();
				$row->bind($row);
				$row->store();
			}
			//Set open graph tags
			if(JRequest::getVar('view','','get') == 'article' || (JRequest::getVar('option','','get') == 'com_k2' && JRequest::getVar('view','','get') == 'item')){
				if(isset($article->slug)){
					require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
					$link = ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid);
				}elseif(method_exists('K2HelperRoute','getItemRoute')){
					$link = K2HelperRoute::getItemRoute($article->id.':'.urlencode($article->alias),$article->catid.':'.urlencode($article->category->alias));
				}else{
					error_log('myApi unable to calculate link for the article id '.$article->id);
					return;
				}
				$u =& JURI::getInstance( JURI::base().$link );
				$port 	= ($u->getPort() == '') ? '' : ":".$u->getPort();
				$articleURL = 'http://'.$u->getHost().$port.$u->getPath().'?'.$u->getQuery();
				$rawText = strip_tags($article->introtext);
				$newTags = array();
				$newTags['og:title'] 		= $article->title;
				$newTags['og:description'] 	= (strlen($rawText) > 247) ? substr($rawText,0,247).'...' : $rawText;
				$newTags['og:type']	= 'article';
				$newTags['og:author']	= (is_object($article->author)) ? $article->author->name : $article->author;
				$newTags['og:url'] 	= $articleURL;
				if($attribs->get('ogimage','0') != '0') $newTags['og:image'] = $attribs->get('ogimage');
				
				plgSystemmyApiOpenGraph::setTags($newTags);
			}
		}
	}
Ejemplo n.º 2
0
 function run($form, $actiondata)
 {
     $params = new JParameter($actiondata->params);
     $mainframe =& JFactory::getApplication();
     //save the data to db
     $db_save_details = $actiondata;
     $db_save_details->type = 'db_save';
     //create params
     $db_save_details_params = new JParameter('');
     $db_save_details_params->set('table_name', $mainframe->getCfg('dbprefix') . 'content');
     $db_save_details_params->set('model_id', 'Article');
     $db_save_details->params = $db_save_details_params->toString();
     //set data
     $user =& JFactory::getUser();
     $form->data['created_by'] = $user->id;
     $form->data['created'] = date("Y-m-d H:i:s");
     $form->data['catid'] = $params->get('catid', '');
     $form->data['sectionid'] = $params->get('sectionid', 0);
     $form->data['state'] = $params->get('state', 0);
     $form->data['title'] = $form->data[$params->get('title', '')];
     $form->data['fulltext'] = $form->data[$params->get('fulltext', '')];
     $form->data['introtext'] = isset($form->data[$params->get('introtext', '')]) ? $form->data[$params->get('introtext', '')] : '';
     $form->data['created_by_alias'] = $form->data[$params->get('created_by_alias', '')];
     //alias
     $form->data['alias'] = JFilterOutput::stringURLSafe($form->data['title']);
     $form->data['id'] = null;
     //$form->data['alias'] = null;
     $form->runAction($db_save_details);
 }
 /**
  * Up
  **/
 public function up()
 {
     $query = "CREATE TABLE IF NOT EXISTS `jos_announcements` (\n\t\t\t\t\t\t`id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t`scope` varchar(100) DEFAULT NULL,\n\t\t\t\t\t\t`scope_id` int(11) DEFAULT NULL,\n\t\t\t\t\t\t`content` text,\n\t\t\t\t\t\t`priority` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t\t`created_by` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t`state` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t\t`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t\t`sticky` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
     $this->db->setQuery($query);
     $this->db->query();
     $params = array('plugin_access' => 'members', 'display_tab' => 1);
     $this->addPluginEntry('groups', 'announcements', 1, $params);
     //get citation params
     if ($this->db->tableExists('#__extensions')) {
         $sql = "SELECT `params` FROM `#__extensions` WHERE `type`='plugin' AND `element`='messages' AND `folder` = 'groups'";
     } else {
         $sql = "SELECT `params` FROM `#__plugins` WHERE `element`='messages' AND `folder`='groups'";
     }
     $this->db->setQuery($sql);
     $p = $this->db->loadResult();
     //load params object
     $params = new \JParameter($p);
     //set param to hide messages tab
     $params->set('display_tab', 0);
     //save new params
     if ($this->db->tableExists('#__extensions')) {
         $query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote(json_encode($params->toArray())) . " WHERE `element`='messages' AND `folder`='groups'";
     } else {
         $query = "UPDATE `#__plugins` SET `params`='" . $params->toString() . "' WHERE `element`='messages' AND `folder`='groups'";
     }
     $this->db->setQuery($query);
     $this->db->query();
 }
    function loadAction($form, $actiondata)
    {
        $params = new JParameter($actiondata->params);
        $output = '';
        $mainframe =& JFactory::getApplication();
        $document =& JFactory::getDocument();
        JHTML::_('behavior.mootools');
        $uri =& JFactory::getURI();
        $CF_PATH = $mainframe->isSite() ? JURI::Base() : $uri->root();
        $document->addScript($CF_PATH . 'administrator/components/com_chronoforms/form_actions/auto_javascript_validation/assets/auto_javascript_validation.js');
        $rules = array('required', 'alpha', 'alphanum', 'digit', 'nodigit', 'number', 'email', 'phone', 'phone_inter', 'url', 'image');
        ob_start();
        ?>
			window.addEvent('domready', function() {
				<?php 
        $object_list = array();
        foreach ($rules as $rule) {
            $fields_list = array();
            if (trim($params->get($rule, ''))) {
                $fields_list = explode(',', trim($params->get($rule, '')));
            }
            foreach ($fields_list as $k => $field) {
                $fields_list[$k] = "'" . $field . "'";
            }
            $n_fields_list = implode(',', $fields_list);
            $object_list[] = "'" . $rule . "': [" . $n_fields_list . "]";
        }
        ?>
				new AutoJavascriptValidation('<?php 
        echo $form->form_name;
        ?>
', <?php 
        echo "{" . implode(",", $object_list) . "}";
        ?>
);
			});
		<?php 
        $script = ob_get_clean();
        if ((bool) $form->form_params->get('dynamic_files', 0) === false) {
            $document->addScriptDeclaration("//<![CDATA[" . "\n" . $script . "\n" . "//]]>");
        } else {
            //load the action class
            $form->loadActionHelper('load_js');
            $CfactionLoadJsHelper = new CfactionLoadJsHelper();
            $JSactiondata = new stdClass();
            $JSactiondata->content1 = $script;
            $JSParams = new JParameter('');
            $JSParams->set('dynamic_file', $form->form_params->get('dynamic_files', 0));
            $JSactiondata->params = $JSParams->toString();
            $CfactionLoadJsHelper->load($form, $JSactiondata);
        }
        //load validation files
        $form->loadActionHelper('show_html');
        $CfactionShowHtmlHelper = new CfactionShowHtmlHelper();
        $CfactionShowHtmlHelper->_loadValidationScripts($form);
    }
Ejemplo n.º 5
0
 /**
  * Saves a configuration
  * 
  * @param KCommandContext $context
  * 
  * @return 
  */
 protected function _actionSave(KCommandContext $context)
 {
     $context->append(array('data' => array('params' => array())));
     //find or create a new component
     $component = $this->getService('repos://admin/components.component')->findOrAddNew(array('option' => 'com_' . $this->getIdentifier()->package), array('data' => array('name' => ucfirst($this->getIdentifier()->package))));
     $params = new JParameter('');
     $params->loadArray((array) $context->data['params']);
     $component->params = $params->toString();
     $component->save();
 }
Ejemplo n.º 6
0
 function &getIni()
 {
     static $ini = 0;
     if (empty($ini)) {
         $basepath = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jdefender';
         $p = new JParameter('');
         $conf = JD_Vars_Helper::getGroup('configuration');
         $p->bind($conf);
         $ini = $p->toString('ini');
     }
     return $ini;
 }
Ejemplo n.º 7
0
 /**
  * Method to block either an email address or an IP from submitting data
  *
  * @access	public
  * @param	string	$type	The type of entity to block (eg. email, ip)
  * @param	array	$ids	The items to extract block data from
  * @return	mixed	Boolean true on success, or JException on failure
  * @since	1.0
  */
 function block($type, $ids)
 {
     // make sure we have addresses to block
     if (empty($ids)) {
         return new JException('No item(s) supplied');
     }
     // sanitize array
     jimport('joomla.utilities.arrayhelper');
     JArrayHelper::toInteger($ids);
     // get the data to set based on the block type
     switch ($type) {
         case 'address':
             // get a database connection object
             $db =& $this->getDBO();
             // get the list of addresses to block
             $db->setQuery('SELECT `address`' . ' FROM `#__jxcomments_comments`' . ' WHERE `id` IN (' . implode(',', $ids) . ')');
             if ($list = $db->loadResultArray()) {
                 // load the component data for com_comments
                 $table =& JTable::getInstance('component');
                 if (!$table->loadByOption('com_comments')) {
                     $this->setError($table->getError());
                     return false;
                 }
                 // get the existing blocked addresses and add the new ones to it
                 $params = new JParameter($table->params);
                 $blocked = $params->get('blockips');
                 foreach (explode(',', $blocked) as $ip) {
                     if ($ip = trim($ip)) {
                         $list[] = trim($ip);
                     }
                 }
                 // remove duplicates and set the blocked addresses in the configuration object
                 $list = array_unique($list);
                 $params->set('blockips', implode(', ', $list));
                 $table->set('params', $params->toString());
                 // check the row.
                 if (!$table->check()) {
                     $this->setError($table->getError());
                     return false;
                 }
                 // store the row.
                 if (!$table->store()) {
                     $this->setError($table->getError());
                     return false;
                 }
                 return true;
             }
             break;
         default:
             return new JException('Unknown block type');
             break;
     }
 }
Ejemplo n.º 8
0
 public function save()
 {
     $data = self::$registry->toString('INI');
     $db = JFactory::getDBO();
     // An interesting discovery: if your component is manually updating its
     // component parameters before Live Update is called, then calling Live
     // Update will reset the modified component parameters because
     // JComponentHelper::getComponent() returns the old, cached version of
     // them. So, we have to forget the following code and shoot ourselves in
     // the feet. Dammit!!!
     /*
     jimport('joomla.html.parameter');
     jimport('joomla.application.component.helper');
     $component =& JComponentHelper::getComponent(self::$component);
     $params = new JParameter($component->params);
     $params->setValue(self::$key, $data);
     */
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $sql = 'SELECT ' . $db->nameQuote('params') . ' FROM ' . $db->nameQuote('#__extensions') . ' WHERE ' . $db->nameQuote('type') . ' = ' . $db->Quote('component') . ' AND ' . $db->nameQuote('element') . ' = ' . $db->Quote(self::$component);
         $db->setQuery($sql);
     } else {
         $sql = 'SELECT ' . $db->nameQuote('params') . ' FROM ' . $db->nameQuote('#__components') . ' WHERE ' . $db->nameQuote('option') . ' = ' . $db->Quote(self::$component) . " AND `parent` = 0 AND `menuid` = 0";
         $db->setQuery($sql);
     }
     $rawparams = $db->loadResult();
     $params = new JParameter($rawparams);
     $params->setValue(self::$key, $data);
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         // Joomla! 1.6
         $data = $params->toString('JSON');
         $sql = 'UPDATE `#__extensions` SET `params` = ' . $db->Quote($data) . ' WHERE ' . "`element` = " . $db->Quote(self::$component) . " AND `type` = 'component'";
     } else {
         // Joomla! 1.5
         $data = $params->toString('INI');
         $sql = 'UPDATE `#__components` SET `params` = ' . $db->Quote($data) . ' WHERE ' . "`option` = " . $db->Quote(self::$component) . " AND `parent` = 0 AND `menuid` = 0";
     }
     $db->setQuery($sql);
     $db->query();
 }
Ejemplo n.º 9
0
 function saveItemPrices($d)
 {
     $params = new JParameter();
     $params->set('price_powerseller', JArrayHelper::getValue($d, 'price_powerseller'));
     $params->set('price_verified', JArrayHelper::getValue($d, 'price_verified'));
     $params->set('category_pricing_enabled', JArrayHelper::getValue($d, 'category_pricing_enabled'));
     $p = $params->toString('INI');
     $price = JArrayHelper::getValue($d, 'default_price');
     $currency = JArrayHelper::getValue($d, 'currency');
     $db = $this->getDbo();
     $db->setQuery("update `#__" . APP_PREFIX . "_pricing`\r\n            set `price`='{$price}',`currency`='{$currency}',\r\n            `params`='{$p}'\r\n            where `itemname`='" . $this->name . "'");
     $db->query();
 }
Ejemplo n.º 10
0
 public function getSlices(JParameter &$params)
 {
     $conf =& JFactory::getConfig();
     if ($conf->getValue('config.caching') && $params->get('module_cache')) {
         $user =& JFactory::getUser();
         $cache =& JFactory::getCache('mod_rokgallery');
         $cache->setCaching(true);
         $args = array($params);
         $checksum = md5($params->toString());
         $slices = $cache->get(array($this, '_getSlices'), $args, 'mod_rokgallery-' . $user->get('aid', 0) . '-' . $checksum);
     } else {
         $slices = $this->_getSlices($params);
     }
     return $slices;
 }
Ejemplo n.º 11
0
 function defr()
 {
     if (!JRequest::checkToken('request')) {
         return $this->setRedirect(index, 'invalid token');
     }
     $r = 'div.linkr-rl {' . "\n" . ' margin-top:20px;' . "\n" . ' padding:10px 5px 0 5px;' . "\n" . ' border-top:1px dotted #ccc;' . "\n" . '}' . "\n" . 'div.linkr-rl div.linkr-rl-t {' . "\n" . ' font-size:1.1em;' . "\n" . ' letter-spacing:2px;' . "\n" . ' text-transform:uppercase;' . "\n" . '}' . "\n" . 'div.linkr-rl ul {' . "\n" . ' list-style-type:square;' . "\n" . ' line-height:1.5em;' . "\n" . ' text-indent:5px;' . "\n" . '}' . "\n" . 'div.linkr-rl ul li {' . "\n" . ' padding:0 5px;' . "\n" . ' background:none;' . "\n" . '}';
     // Restore default
     $table =& JTable::getInstance('component');
     $table->loadByOption('com_linkr');
     $params = new JParameter($table->params);
     $params->set('rcss', base64_encode($r));
     $table->params = $params->toString();
     $m = $table->store() ? JText::_('NOTICE_SAVED') : $table->getError();
     $this->setRedirect(index . '&view=css', $m);
 }
Ejemplo n.º 12
0
    function load($form = null, $actiondata = null)
    {
        $params = new JParameter($actiondata->params);
        $document =& JFactory::getDocument();
        JHTML::_('behavior.mootools');
        $mainframe =& JFactory::getApplication();
        $uri =& JFactory::getURI();
        $CF_PATH = $mainframe->isSite() ? JURI::Base() : $uri->root();
        $document->addStyleSheet($CF_PATH . 'components/com_chronoforms/css/datepicker/datepicker_dashboard.css');
        $document->addScript($CF_PATH . 'components/com_chronoforms/js/datepicker/datepicker.js');
        $con_str = "'." . $params->get('field_class', 'cf_datetime_picker') . "', {pickerClass: '" . $params->get('pickerClass', 'datepicker_dashboard') . "', format: '" . $params->get('format', 'd-m-Y H:i:s') . "', inputOutputFormat: '" . $params->get('inputOutputFormat', 'Y-m-d H:i:s') . "', allowEmpty: " . $params->get('allowEmpty', 'true') . ", timePicker: " . $params->get('timePicker', 'true') . ", timePickerOnly: " . $params->get('timePickerOnly', 'false');
        ob_start();
        eval('?>' . $actiondata->content1);
        $actiondata->content1 = ob_get_clean();
        if (!empty($actiondata->content1)) {
            $con_str .= ", " . $actiondata->content1;
            $con_str .= "}";
        } else {
            $con_str .= "}";
        }
        ob_start();
        ?>
			window.addEvent('load', function() {
				new DatePicker(<?php 
        echo $con_str;
        ?>
);
			});
		<?php 
        $script = ob_get_clean();
        if ((bool) $form->form_params->get('dynamic_files', 0) === false) {
            $document->addScriptDeclaration("//<![CDATA[" . "\n" . $script . "\n" . "//]]>");
        } else {
            //load the action class
            $form->loadActionHelper('load_js');
            $CfactionLoadJsHelper = new CfactionLoadJsHelper();
            $JSactiondata = new stdClass();
            $JSactiondata->content1 = $script;
            $JSParams = new JParameter('');
            $JSParams->set('dynamic_file', $form->form_params->get('dynamic_files', 0));
            $JSactiondata->params = $JSParams->toString();
            $CfactionLoadJsHelper->load($form, $JSactiondata);
        }
    }
Ejemplo n.º 13
0
    function run($form, $actiondata)
    {
        ob_start();
        ?>
		function(){
			$('chronoform_<?php 
        echo $form->form_name;
        ?>
').removeClass('hasValidation');
			request_caller_<?php 
        echo $actiondata->id;
        ?>
();
		}
		<?php 
        $jsvalidation_onValidateSuccess = ob_get_clean();
        $form_params = new JParameter($form->form_details->params);
        $form_params->set('jsvalidation_onValidateSuccess', $jsvalidation_onValidateSuccess);
        $form->form_params->set('jsvalidation_onValidateSuccess', $jsvalidation_onValidateSuccess);
        $form->form_details->params = $form_params->toString();
    }
Ejemplo n.º 14
0
 function run($form, $actiondata)
 {
     $mainframe = JFactory::getApplication();
     $uri = JFactory::getURI();
     $params = new JParameter($actiondata->params);
     //save the data to db
     $db_save_details = $actiondata;
     $db_save_details->type = 'db_save';
     $db_save_Params = new JParameter('');
     $db_save_Params->set('table_name', $params->get('table_name'));
     $db_save_details->params = $db_save_Params->toString();
     $form->data[trim($params->get('verify_field', 'verify'))] = md5(uniqid(rand(), true));
     $form->data[trim($params->get('verification_status_field', 'verified'))] = 0;
     if (trim($params->get('files_array_field', ''))) {
         $form->data[trim($params->get('files_array_field'))] = var_export($form->files, true);
     }
     $form->runAction($db_save_details);
     //add the verification link value to the data array
     $form->data['verification_link'] = $params->get('verification_link_path', $uri->root() . 'index.php?option=com_chronoforms&amp;chronoform=' . $form->form_name);
     $form->data['verification_link'] .= '&amp;action=verify&amp;hash=' . $form->data[trim($params->get('verify_field', 'verify'))];
 }
Ejemplo n.º 15
0
 function saveItemPrices($d)
 {
     $params = new JParameter();
     $params->set('price_powerseller', JArrayHelper::getValue($d, 'price_powerseller'));
     $params->set('price_verified', JArrayHelper::getValue($d, 'price_verified'));
     $params->set('category_pricing_enabled', JArrayHelper::getValue($d, 'category_pricing_enabled'));
     $p = $params->toString('INI');
     $price = JArrayHelper::getValue($d, 'default_price');
     $currency = JArrayHelper::getValue($d, 'currency');
     $db = $this->getDbo();
     $db->setQuery("update `#__" . APP_PREFIX . "_pricing`\r\n            set `price`='{$price}',`currency`='{$currency}',\r\n            `params`='{$p}'\r\n            where `itemname`='listing'");
     $db->query();
     $db->setQuery("delete from `#__" . APP_PREFIX . "_pricing_categories` where `itemname`='" . $this->name . "'");
     $db->query();
     $category_pricing = JArrayHelper::getValue($d, 'category_pricing', array(), 'array');
     foreach ($category_pricing as $k => $v) {
         if (!empty($v) || $v === '0') {
             $db->setQuery("insert into `#__" . APP_PREFIX . "_pricing_categories` (`category`,`price`,`itemname`) values ('{$k}','{$v}','" . $this->name . "')");
             $db->query();
         }
     }
 }
Ejemplo n.º 16
0
 function run($form, $actiondata)
 {
     $params = new JParameter($actiondata->params);
     $session_key = $form->getSessionToken();
     //Data to Session config
     $data_to_session_details = new stdClass();
     $data_to_session_details->type = 'data_to_session';
     $data_to_session_Params = new JParameter('');
     $data_to_session_Params->set('merge', 1);
     if ((bool) $params->get('session_key', 0) === true) {
         $data_to_session_Params->set('key', $session_key);
     }
     $data_to_session_details->params = $data_to_session_Params->toString();
     $form->runAction($data_to_session_details);
     //Session to Data config
     $session_to_data_details = new stdClass();
     $session_to_data_details->type = 'session_to_data';
     $session_to_data_Params = new JParameter('');
     if ((bool) $params->get('session_key', 0) === true) {
         $session_to_data_Params->set('key', $session_key);
     }
     $session_to_data_details->params = $session_to_data_Params->toString();
     $form->runAction($session_to_data_details);
 }
Ejemplo n.º 17
0
 function createAction($action_name, $params = array())
 {
     $new_action_details = new stdClass();
     $new_action_details->type = $action_name;
     $new_action_details->enabled = 1;
     if (!empty($params['enabled'])) {
         $new_action_details->enabled = (int) $params['enabled'];
     }
     $new_action_details->content1 = '';
     if (!empty($params['content1'])) {
         $new_action_details->content1 = $params['content1'];
     }
     $new_action_Params = new JParameter('');
     foreach ($params as $k => $v) {
         $new_action_Params->set($k, $v);
     }
     $new_action_details->params = $new_action_Params->toString();
     return $new_action_details;
 }
Ejemplo n.º 18
0
function _save_form_wizard()
{
    //generate XML code for the form
    $chronoform = array();
    $formdata = array();
    if (!empty($_POST['chronofield'])) {
        foreach ($_POST['chronofield'] as $key => $fielddata) {
            $formdata['field_' . $key] = array();
            foreach ($fielddata as $fieldname => $fieldvalue) {
                $formdata['field_' . $key][$fieldname] = $fieldvalue;
            }
        }
    }
    //if easy mode, load the preset events actions
    if (isset($_POST['wizard_mode']) && $_POST['wizard_mode'] == 'easy') {
        $_POST['chronoaction'][3] = array('type' => 'show_html');
        $_POST['chronoaction'][5] = array('type' => 'event_loop');
        $_POST['chronoaction'][7] = array('type' => 'event_loop');
        $_POST['chronoaction'][16] = array('type' => 'handle_arrays');
    }
    //prepare the actions details for the model
    $formactionsdata = array();
    $action_count = 0;
    if (!empty($_POST['chronoaction'])) {
        foreach ($_POST['chronoaction'] as $key => $actiondata) {
            $type = $_data['ChronoformAction'][$action_count]['type'] = $actiondata['type'];
            $_data['ChronoformAction'][$action_count]['order'] = $key;
            if (isset($actiondata['action_' . $actiondata['type'] . '_' . $key . '_enabled'])) {
                $_data['ChronoformAction'][$action_count]['enabled'] = $actiondata['action_' . $actiondata['type'] . '_' . $key . '_enabled'];
                unset($actiondata['action_' . $actiondata['type'] . '_' . $key . '_enabled']);
            } else {
                $_data['ChronoformAction'][$action_count]['enabled'] = 1;
            }
            //$_data['ChronoformAction'][$action_count]['event'] = $actiondata['action_'.$actiondata['type'].'_'.$key.'_event'];
            //unset($actiondata['action_'.$actiondata['type'].'_'.$key.'_event']);
            if (isset($actiondata['action_' . $actiondata['type'] . '_' . $key . '_content1'])) {
                $_data['ChronoformAction'][$action_count]['content1'] = $actiondata['action_' . $actiondata['type'] . '_' . $key . '_content1'];
                unset($actiondata['action_' . $actiondata['type'] . '_' . $key . '_content1']);
            }
            unset($actiondata['type']);
            foreach ($actiondata as $actionname => $actionvalue) {
                $actiondata[str_replace('action_' . $type . '_' . $key . '_', '', $actionname)] = $actionvalue;
                unset($actiondata[$actionname]);
            }
            $_data['ChronoformAction'][$action_count]['params'] = $actiondata;
            $action_count++;
        }
    }
    $chronoform['formcode'] = $formdata;
    /*print_r2($_data);
    	die();
    	/*echo '<pre>';
    	print_r($formdata);
    	print_r($_data);
    	print_r($_POST['_form_actions_events_map']);
    	echo '</pre>';*/
    //save form
    $mainframe =& JFactory::getApplication();
    $database =& JFactory::getDBO();
    $row = JTable::getInstance('chronoforms', 'Table');
    if (isset($_POST['data']['Chronoform']['id']) && !empty($_POST['data']['Chronoform']['id'])) {
        $_data['Chronoform']['id'] = $_POST['data']['Chronoform']['id'];
        if (isset($_POST['wizard_mode'])) {
            // && $_POST['wizard_mode'] == 'easy'){
            //load the form
            $database =& JFactory::getDBO();
            $database->setQuery("SELECT * FROM #__chronoforms WHERE id='" . $_data['Chronoform']['id'] . "'");
            $form = $database->loadObject();
            //$_data['Chronoform']['params'] = 'form_mode='.$_POST['wizard_mode'].''."\n".trim($form->params)."\n".'form_mode='.$_POST['wizard_mode'];
            $form_params = new JParameter($form->params);
            $form_params->set('form_mode', $_POST['wizard_mode']);
            $form_params->set('tight_layout', $_POST['params']['tight_layout']);
            $_data['Chronoform']['params'] = $form_params->toString();
        }
    } else {
        $_data['Chronoform']['form_type'] = 1;
        //this is a new form, set it as WIZARD form
        if (isset($_POST['wizard_mode'])) {
            // && $_POST['wizard_mode'] == 'easy'){
            //$_data['Chronoform']['params'] = 'form_mode='.$_POST['wizard_mode'];
            $form_params = new JParameter('');
            $form_params->set('form_mode', $_POST['wizard_mode']);
            $form_params->set('tight_layout', $_POST['params']['tight_layout']);
            $_data['Chronoform']['params'] = $form_params->toString();
        }
    }
    $_data['Chronoform']['name'] = $_POST['chronoform_name'];
    $_data['Chronoform']['published'] = $_POST['chronoform_published'];
    if (isset($_POST['form_type']) && (int) $_POST['form_type'] != 0) {
        $_data['Chronoform']['content'] = _processWizardCode($formdata);
        $_data['Chronoform']['wizardcode'] = var_export($formdata, true);
        /*if(strpos($form->form_details->content, 'validate[') !== false){
        			
        		}*/
    }
    //get the actions events map
    $_data['Chronoform']['events_actions_map'] = base64_encode(serialize($_POST['_form_actions_events_map']['myform']));
    //if easy mode, load the preset events map
    if (isset($_POST['wizard_mode']) && $_POST['wizard_mode'] == 'easy') {
        $_data['Chronoform']['events_actions_map'] = "YToxOntzOjY6ImV2ZW50cyI7YToyOntzOjQ6ImxvYWQiO2E6MTp7czo3OiJhY3Rpb25zIjthOjQ6e3M6MTg6ImNmYWN0aW9uX2xvYWRfanNfMCI7czowOiIiO3M6MTk6ImNmYWN0aW9uX2xvYWRfY3NzXzEiO3M6MDoiIjtzOjIzOiJjZmFjdGlvbl9sb2FkX2NhcHRjaGFfMiI7czowOiIiO3M6MjA6ImNmYWN0aW9uX3Nob3dfaHRtbF8zIjtzOjA6IiI7fX1zOjY6InN1Ym1pdCI7YToxOntzOjc6ImFjdGlvbnMiO2E6MTA6e3M6MjQ6ImNmYWN0aW9uX2NoZWNrX2NhcHRjaGFfNCI7YToxOntzOjY6ImV2ZW50cyI7YToyOntzOjM3OiJjZmFjdGlvbmV2ZW50X2NoZWNrX2NhcHRjaGFfNF9zdWNjZXNzIjtzOjA6IiI7czozNDoiY2ZhY3Rpb25ldmVudF9jaGVja19jYXB0Y2hhXzRfZmFpbCI7YToxOntzOjc6ImFjdGlvbnMiO2E6MTp7czoyMToiY2ZhY3Rpb25fZXZlbnRfbG9vcF81IjtzOjA6IiI7fX19fXM6MjM6ImNmYWN0aW9uX3VwbG9hZF9maWxlc182IjthOjE6e3M6NjoiZXZlbnRzIjthOjI6e3M6MzY6ImNmYWN0aW9uZXZlbnRfdXBsb2FkX2ZpbGVzXzZfc3VjY2VzcyI7czowOiIiO3M6MzM6ImNmYWN0aW9uZXZlbnRfdXBsb2FkX2ZpbGVzXzZfZmFpbCI7YToxOntzOjc6ImFjdGlvbnMiO2E6MTp7czoyMToiY2ZhY3Rpb25fZXZlbnRfbG9vcF83IjtzOjA6IiI7fX19fXM6MjI6ImNmYWN0aW9uX2N1c3RvbV9jb2RlXzgiO3M6MDoiIjtzOjI1OiJjZmFjdGlvbl9oYW5kbGVfYXJyYXlzXzE2IjtzOjA6IiI7czoxODoiY2ZhY3Rpb25fZGJfc2F2ZV85IjtzOjA6IiI7czoxNzoiY2ZhY3Rpb25fZW1haWxfMTAiO3M6MDoiIjtzOjE3OiJjZmFjdGlvbl9lbWFpbF8xMSI7czowOiIiO3M6MTc6ImNmYWN0aW9uX2VtYWlsXzEyIjtzOjA6IiI7czoyMzoiY2ZhY3Rpb25fY3VzdG9tX2NvZGVfMTMiO3M6MDoiIjtzOjMxOiJjZmFjdGlvbl9zaG93X3RoYW5rc19tZXNzYWdlXzE0IjtzOjA6IiI7fX19fQ==";
    }
    if (!$row->bind($_data['Chronoform'])) {
        JError::raiseWarning(100, $row->getError());
        $mainframe->redirect("index.php?option=com_chronoforms");
    }
    if (!$row->store()) {
        JError::raiseWarning(100, $row->getError());
        $mainframe->redirect("index.php?option=com_chronoforms");
    }
    $chronoform_id = $row->id;
    //save actions
    if (isset($_data['ChronoformAction']) && !empty($_data['ChronoformAction'])) {
        //delete previous actions to save new ones
        if (isset($_POST['data']['Chronoform']['id']) && !empty($_POST['data']['Chronoform']['id'])) {
            $database->setQuery("DELETE FROM #__chronoform_actions WHERE chronoform_id='" . $_POST['data']['Chronoform']['id'] . "'");
            if (!$database->query()) {
                JError::raiseWarning(100, $row->getError());
                $mainframe->redirect("index.php?option=com_chronoforms");
            }
        }
        //save all new actions
        foreach ($_data['ChronoformAction'] as $action) {
            $row = JTable::getInstance('chronoformactions', 'Table');
            $action['chronoform_id'] = $chronoform_id;
            $params = new JParameter('');
            if (isset($action['params']) && is_array($action['params'])) {
                foreach ($action['params'] as $k => $param) {
                    $params->set($k, $param);
                }
                $action['params'] = $params->toString();
            }
            if (!$row->bind($action)) {
                JError::raiseWarning(100, $row->getError());
                $mainframe->redirect("index.php?option=com_chronoforms");
            }
            if (!$row->store()) {
                JError::raiseWarning(100, $row->getError());
                $mainframe->redirect("index.php?option=com_chronoforms");
            }
        }
    }
    return $chronoform_id;
}
    function load($form = null, $actiondata = null)
    {
        $params = new JParameter($actiondata->params);
        $document =& JFactory::getDocument();
        JHTML::_('behavior.mootools');
        $mainframe =& JFactory::getApplication();
        $uri =& JFactory::getURI();
        //check picker types
        $jversion = new JVersion();
        $script = "";
        if ($jversion->RELEASE > 1.5 && $form->form_params->get('datepicker_type', 0) == 1) {
            $cf_url = $uri->root();
            $cf_url .= 'components/com_chronoforms/js/datepicker_moo/';
            // you can change the uncommented line here to change the style
            $datepicker_style = $params->get('pickerClass', 'datepicker_dashboard');
            $document->addStyleSheet($cf_url . $datepicker_style . '/' . $datepicker_style . '.css');
            $document->addScript($cf_url . 'Locale.en-US.DatePicker.js');
            $document->addScript($cf_url . 'Picker.js');
            $document->addScript($cf_url . 'Picker.Attach.js');
            $document->addScript($cf_url . 'Picker.Date.js');
            if ((bool) $params->get('pickOnly', 0) === false) {
                $pickOnly = 'false';
            } else {
                $pickOnly = "'" . $params->get('pickOnly', 0) . "'";
            }
            $con_str = "\$\$('." . $params->get('field_class', 'cf_datetime_picker') . "'), {pickerClass: '" . $params->get('pickerClass', 'datepicker_dashboard') . "', format: '" . $params->get('format', 'd-m-Y H:i:s') . "', allowEmpty: " . $params->get('allowEmpty', 'true') . ", timePicker: " . $params->get('timePicker', 'true') . ", pickOnly: " . $pickOnly . "";
            $pickerClass = "Picker.Date";
            ob_start();
            eval('?>' . $actiondata->content1);
            $actiondata->content1 = ob_get_clean();
            if (!empty($actiondata->content1)) {
                $con_str .= ", " . $actiondata->content1;
                $con_str .= "}";
            } else {
                $con_str .= "}";
            }
            ob_start();
            ?>
				window.addEvent('load', function() {
					new <?php 
            echo $pickerClass;
            ?>
(<?php 
            echo $con_str;
            ?>
);
				});
			<?php 
            $script = ob_get_clean();
        }
        if ((bool) $form->form_params->get('dynamic_files', 0) === false) {
            $document->addScriptDeclaration("//<![CDATA[" . "\n" . $script . "\n" . "//]]>");
        } else {
            //load the action class
            $form->loadActionHelper('load_js');
            $CfactionLoadJsHelper = new CfactionLoadJsHelper();
            $JSactiondata = new stdClass();
            $JSactiondata->content1 = $script;
            $JSParams = new JParameter('');
            $JSParams->set('dynamic_file', $form->form_params->get('dynamic_files', 0));
            $JSactiondata->params = $JSParams->toString();
            $CfactionLoadJsHelper->load($form, $JSactiondata);
        }
    }
Ejemplo n.º 20
0
jimport('joomla.environment.response');
jimport('joomla.language.language');
jimport('joomla.user.user');
jimport('joomla.application.component.model');
jimport('joomla.database.table');
jimport('joomla.html.parameter');
jimport('joomla.plugin.helper');
jimport('joomla.event.dispatcher');
/* load JCK loader class*/
require_once CKEDITOR_INCLUDES_DIR . '/loader.php';
//lets set DB configuration
$config = new JConfig();
// Get the global configuration object
$registry =& JFactory::getConfig();
// Load the configuration values into the registry
$registry->loadObject($config);
//set session
jckimport('ckeditor.user.user');
$session =& JCKUser::getSession();
// system events trigger events
jckimport('ckeditor.plugins.helper');
//load CK System plugins
JCKPluginsHelper::storePlugins('default');
$dispatcher =& JDispatcher::getInstance();
$plugin =& JPluginHelper::getPlugin('editors', 'jckeditor');
$params = new JParameter($plugin->params);
//import System plugin first
JCKPluginsHelper::importPlugin('default');
$dispatcher->trigger('intialize', array(&$params));
$plugin->params = $params->toString();
Ejemplo n.º 21
0
 function saveGeneral($post = null)
 {
     global $mainframe;
     t3_import('core/admin/util');
     // Initialize some variables
     $db =& JFactory::getDBO();
     $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
     if (!$post) {
         $json = JRequest::getVar('json');
         $json = str_replace(array("\\n", "\\t"), array("\n", "\t"), $json);
         $json = str_replace('\\', '', $json);
         $post = json_decode($json);
     }
     $template = JRequest::getCmd('template');
     $result = array();
     if (!$template) {
         $result['error'] = JText::_('Operation Failed') . ': ' . JText::_('No template specified.');
         echo json_encode($result);
         exit;
     }
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $errors = array();
     if ($post) {
         if (isset($post)) {
             $file = $client->path . DS . 'templates' . DS . $template . DS . 'params.ini';
             $params = new JParameter('');
             foreach ($post as $k => $v) {
                 $v = str_replace(array("\\n", "\\t"), array("\n", "\t"), $v);
                 $v = str_replace('\\', '', $v);
                 $params->set($k, $v);
             }
             $data = $params->toString();
             if (JFile::exists($file)) {
                 @chmod($file, 0777);
             }
             $return = JFile::write($file, $data);
             // Try to make the params file unwriteable
             if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
                 $errors[] = sprintf(JText::_('Could not make the %s file unwritable'), $file);
             }
             if (!$return) {
                 $errors[] = JText::_('Operation Failed') . ': ' . JText::sprintf('Failed to open file for writing.', $file);
             }
         }
     }
     if (JRequest::getCmd('jat3action') != 'saveGeneral') {
         return $errors;
     }
     if ($errors) {
         $result['error'] = implode('<br/>', $errors);
     } else {
         $result['successful'] = JText::_('SAVE DATA SUCCESSFULLY');
     }
     echo json_encode($result);
     exit;
 }
Ejemplo n.º 22
0
 public function save()
 {
     jimport('joomla.user.helper');
     // Load the old row if editing an existing user.
     if (!$this->_new) {
         $old_row = $this->getService('com://admin/users.database.table.users')->select($this->id, KDatabase::FETCH_ROW);
     }
     $user = JFactory::getUser();
     // Validate received data.
     if (($this->_new || isset($this->_modified['name'])) && trim($this->name) == '') {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_('Please enter a name!'));
         return false;
     }
     if (($this->_new || isset($this->_modified['username'])) && trim($this->username) == '') {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_('Please enter a username!'));
         return false;
     }
     if (($this->_new || isset($this->_modified['username'])) && preg_match('#[<>"\'%;()&]#i', $this->username) || strlen(utf8_decode($this->username)) < 2) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_('Please enter a valid username. No spaces, at least 2 characters ' . 'and must contain <strong>only</strong> letters and numbers.'));
         return false;
     }
     if (isset($this->_modified['username'])) {
         $query = $this->getTable()->getDatabase()->getQuery()->where('username', '=', $this->username)->where('id', '<>', (int) $this->id);
         $total = $this->getService('com://admin/users.database.table.users')->count($query);
         if ($total) {
             $this->setStatus(KDatabase::STATUS_FAILED);
             $this->setStatusMessage(JText::_('This username is already in use.'));
             return false;
         }
     }
     if (($this->_new || isset($this->_modified['email'])) && trim($this->email) == '' || !$this->getService('koowa:filter.email')->validate($this->email)) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_('Please enter a valid e-mail address.'));
         return false;
     }
     if (isset($this->_modified['email'])) {
         $query = $this->getTable()->getDatabase()->getQuery()->where('email', '=', $this->email)->where('id', '<>', (int) $this->id);
         $total = $this->getService('com://admin/users.database.table.users')->count($query);
         if ($total) {
             $this->setStatus(KDatabase::STATUS_FAILED);
             $this->setStatusMessage(JText::_('This e-mail address is already registered.'));
             return false;
         }
     }
     /*
      * If username field is an email it has to be the same with email field.
      * This removes the possibilitiy that a user can get locked out of her account
      * if someone else uses that username as the email field.
      */
     if (KService::get('koowa:filter.email')->validate($this->username) === true && $this->username !== $this->email) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_('Your e-mail and username should match if you want to use an e-mail address as your username.'));
         return false;
     }
     // Don't allow users to block themselves.
     if (isset($this->_modified['enabled']) && !$this->_new && $user->id == $this->id && !$this->enabled) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("You can't block yourself!"));
         return false;
     }
     // Don't allow to save a user without a group.
     if (($this->_new || isset($this->_modified['users_group_id'])) && !$this->users_group_id) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("You can't create a user without a user group."));
         return false;
     }
     // Don't allow users below super administrator to edit a super administrator.
     if (!$this->_new && isset($this->_modified['users_group_id']) && $old_row->users_group_id == 25 && $user->gid != 25) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("You can't edit a super administrator account."));
         return false;
     }
     // Don't allow users below super administrator to create an administrators.
     if (isset($this->_modified['users_group_id']) && $this->users_group_id == 24 && !($user->gid == 25 || $user->id == $this->id && $user->gid == 24)) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("You can't create a user with this user group level. " . "Only super administrators have this ability."));
         return false;
     }
     // Don't allow users below super administrator to create a super administrator.
     if (isset($this->_modified['users_group_id']) && $this->users_group_id == 25 && $user->gid != 25) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("You can't create a user with this user group level. " . "Only super administrators have this ability."));
         return false;
     }
     // Don't allow users to change the user level of the last active super administrator.
     if (isset($this->_modifid['users_group_id']) && $old_row->users_group_id != 25) {
         $query = $this->getTable()->getDatabase()->getQuery()->where('users_group_id', '=', 25)->where('enabled', '=', 1);
         $total = $this->getService('com://admin/users.database.table.users')->count($query);
         if ($total <= 1) {
             $this->setStatus(KDatabase::STATUS_FAILED);
             $this->setStatusMessage(JText::_("You can't change this user's group because " . "the user is the only active super administrator for your site."));
             return false;
         }
     }
     // Check if passwords match.
     if (isset($this->_modified['password']) && $this->password != $this->password_verify) {
         $this->setStatus(KDatabase::STATUS_FAILED);
         $this->setStatusMessage(JText::_("Passwords don't match!"));
         return false;
     }
     // Generate a random password if empty and the record is new.
     if ($this->_new && !$this->password) {
         $this->password = $this->getService('com://admin/users.helper.password')->getRandom();
         $this->password_verify = $this->password;
     }
     if (isset($this->_modified['password']) && $this->password) {
         // Encrypt password.
         $salt = $this->getService('com://admin/users.helper.password')->getRandom(32);
         $password = $this->getService('com://admin/users.helper.password')->getCrypted($this->password, $salt);
         $this->password = $password . ':' . $salt;
     } else {
         $this->password = $old_row->password;
         unset($this->_modified['password']);
     }
     if ($this->_new) {
         $this->registered_on = gmdate('Y-m-d H:i:s', time());
     }
     $query = $this->getTable()->getDatabase()->getQuery()->select('name')->where('id', '=', $this->users_group_id);
     $this->group_name = $this->getService('com://admin/users.database.table.groups')->select($query, KDatabase::FETCH_FIELD);
     // Set parameters.
     if (isset($this->_modified['params'])) {
         $params = new JParameter('');
         $params->bind($this->_data['params']);
         $this->params = $params->toString();
         if (!$this->_new && $this->_data['params'] == $old_row->params->toString()) {
             unset($this->_modified['params']);
         }
     }
     // Need to reverse the value of 'enabled', because the mapped column is 'block'.
     if ($this->_new || isset($this->_modified['enabled'])) {
         $this->enabled = $this->enabled ? 0 : 1;
     }
     if (!parent::save()) {
         return false;
     }
     // Syncronize ACL.
     if ($this->_status == KDatabase::STATUS_CREATED) {
         $aro = $this->getService('com://admin/groups.database.row.aro')->setData(array('section_value' => 'users', 'value' => $this->id, 'name' => $this->name));
         $aro->save();
         $this->getService('com://admin/groups.database.row.arosgroup')->setData(array('group_id' => $this->users_group_id, 'aro_id' => $aro->id))->save();
     } else {
         if (isset($this->_modified['name']) || isset($this->_modified['users_group_id'])) {
             $aro = $this->getService('com://admin/groups.database.table.aros')->select(array('value' => $this->id), KDatabase::FETCH_ROW);
             if (isset($this->_modified['name'])) {
                 $aro->name = $this->name;
                 $aro->save();
             }
             if (isset($this->_modified['users_group_id'])) {
                 $this->getService('com://admin/groups.database.table.arosgroups')->select(array('aro_id' => $aro->id), KDatabase::FETCH_ROW)->delete();
                 $this->getService('com://admin/groups.database.table.arosgroups')->select(null, KDatabase::FETCH_ROW)->setData(array('group_id' => $this->users_group_id, 'aro_id' => $aro->id))->save();
             }
         }
     }
     return true;
 }
Ejemplo n.º 23
0
 /**
  * AJAX method to save a field
  * 
  * @param	int	id	Current field id
  * @param	Array data	The fields data
  * 
  * @return	JAXResponse object	Azrul's AJAX Response object
  **/
 function ajaxSaveField($id, $data)
 {
     $user =& JFactory::getUser();
     if ($user->get('guest')) {
         JError::raiseError(403, JText::_('CC ACCESS FORBIDDEN'));
         return;
     }
     $response = new JAXResponse();
     // Load the JTable Object.
     $row =& JTable::getInstance('profiles', 'CommunityTable');
     $row->load($id);
     $isValid = true;
     $row->bindAjaxPost($data);
     // override the option visiable, registration and required for label type.
     if ($row->type == 'label') {
         $row->visible = 0;
         $row->required = 0;
     }
     // Do some validation before blindly saving the profile.
     if (empty($row->name)) {
         $error = JText::_('CC NAME SHOULD NOT BE LEFT EMPTY');
         $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
         $isValid = false;
     }
     if (empty($row->fieldcode)) {
         $error = JText::_('CC FIELD CODE SHOULD NOT BE LEFT EMPTY');
         $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
         $isValid = false;
     }
     if ($row->required && !$row->registration) {
         $error = JText::_('CC A FIELD IN REQUIRED SHOULD SET AS REGISTRATION AS WELL');
         $response->addScriptCall('joms.jQuery("#error-notice").html("' . $error . '");');
         $isValid = false;
     }
     if ($isValid) {
         $groupOrdering = isset($data['group']) ? $data['group'] : '';
         /* Now, save optional params items */
         $xmlPath = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'fields' . DS . $row->type . '.xml';
         if (JFile::exists($xmlPath)) {
             $postvars = $data;
             $post = array();
             // convert $postvars to normal post
             $pattern = "'params\\[(.*?)\\]'s";
             for ($i = 0; $i < count($postvars); $i++) {
                 if (!empty($postvars[$i]) && is_array($postvars[$i])) {
                     $key = $postvars[$i][0];
                     // @TODO: support 'usergroup' param type
                     preg_match($pattern, $key, $matches);
                     if ($matches) {
                         $key = $matches[1];
                         $post[$key] = $postvars[$i][1];
                     }
                 }
             }
             $params = new JParameter('', $xmlPath);
             $params->bind($post);
             $row->params = $params->toString();
         }
         $row->store($groupOrdering);
         $parent = '';
         // Get the view
         $view =& $this->getView('profiles', 'html');
         if ($id != 0) {
             $name = '<a href="javascript:void(0);" onclick="azcommunity.editField(\'' . $row->id . '\');">' . $row->name . '</a>';
             $type = '<span id="type' . $row->id . '" onclick="$(\'typeOption\').style.display = \'block\';$(this).style.display = \'none\';">' . JString::ucfirst($row->type) . '</span>';
             $publish = $view->getPublish($row, 'published', 'profiles,ajaxTogglePublish');
             if ($row->type == 'label') {
                 $required = $view->showPublish($row, 'required');
                 $visible = $view->showPublish($row, 'visible');
             } else {
                 $required = $view->getPublish($row, 'required', 'profiles,ajaxTogglePublish');
                 $visible = $view->getPublish($row, 'visible', 'profiles,ajaxTogglePublish');
             }
             $registration = $view->getPublish($row, 'registration', 'profiles,ajaxTogglePublish');
             // Set the parent id
             $parent = $row->id;
             // Update the rows in the table at the page.
             //@todo: need to update the title in a way looks like Joomla initialize the tooltip on document ready
             $response->addAssign('name' . $row->id, 'innerHTML', $name);
             $response->addAssign('type' . $row->id, 'innerHTML', $type);
             $response->addAssign('published' . $row->id, 'innerHTML', $publish);
             $response->addAssign('required' . $row->id, 'innerHTML', $required);
             $response->addAssign('visible' . $row->id, 'innerHTML', $visible);
             $response->addAssign('registration' . $row->id, 'innerHTML', $registration);
             $response->addAssign('min' . $row->id, 'value', $row->min);
             $response->addAssign('max' . $row->id, 'value', $row->max);
         } else {
             $response->addScriptCall('window.location.href = "' . JURI::base() . 'index.php?option=com_community&view=profiles";');
         }
         $response->addScriptCall('cWindowHide();');
     } else {
         //release the form input back to enabled.
         $response->addScriptCall('joms.jQuery(\'#cWindowContent\').find(\'input, textarea, button\').attr(\'disabled\', false)');
     }
     $response->sendResponse();
 }
Ejemplo n.º 24
0
 function storeParams($table, $id, $db_field, $new_params)
 {
     $row = AcesefFactory::getTable($table);
     if (!$row->load($id)) {
         return false;
     }
     $params = new JParameter($row->{$db_field});
     foreach ($new_params as $name => $value) {
         $params->set($name, $value);
     }
     $row->{$db_field} = $params->toString();
     if (!$row->check()) {
         return false;
     }
     if (!$row->store()) {
         return false;
     }
 }
Ejemplo n.º 25
0
 public function updateTemplate($template)
 {
     jimport('joomla.filesystem.file');
     CFactory::load('helpers', 'string');
     $config =& JTable::getInstance('configuration', 'CommunityTable');
     $config->load('config');
     $params = new JParameter($config->params);
     $params->set('template', $template);
     $config->params = $params->toString();
     // Save it
     if (!$config->store()) {
         return false;
     }
     return true;
 }
Ejemplo n.º 26
0
        echo 'Time        : ' . (xdebug_time_index() - $tm) . '<br/>';
        echo 'Query       : ' . $db->getTicker();
        echo '</pre>';
        // Log average page load
        jimport('joomla.filesystem.file');
        $content = JFile::read(COMMUNITY_COM_PATH . DS . 'access.log');
        $params = new JParameter($content);
        $today = strftime('%Y-%m-%d');
        $loadTime = $params->get($today, 0);
        if ($loadTime > 0) {
            $loadTime = ($loadTime + (xdebug_time_index() - $tm)) / 2;
        } else {
            $loadTime = xdebug_time_index() - $tm;
        }
        $params->set($today, $loadTime);
        JFile::write(COMMUNITY_COM_PATH . DS . 'access.log', $params->toString());
    }
    echo getJomSocialPoweredByLink();
    //	 getTriggerCount
    //	$appLib = CAppPlugins::getInstance();
    //	echo 'Trigger count: '. $appLib->triggerCount . '<br/>';
    //	$time_end = microtime(true);
    //	$time = $time_end - $time_start;
    //	echo $time;
}
/**
 * Entry poitn for all ajax call
 */
function communityAjaxEntry($func, $args = null)
{
    // For AJAX calls, we need to load the language file manually.
Ejemplo n.º 27
0
    function _loadToolTip($form)
    {
        $mainframe =& JFactory::getApplication();
        $uri =& JFactory::getURI();
        $document =& JFactory::getDocument();
        JHTML::_('behavior.mootools');
        $CF_PATH = $mainframe->isSite() ? JURI::Base() : $uri->root();
        echo '<link href="' . $CF_PATH . 'components/com_chronoforms/css/tooltip.css" rel="stylesheet" type="text/css" />';
        //JHTML::_('behavior.tooltip', '.tooltipimg');
        ob_start();
        ?>
			window.addEvent('domready', function(){
				//create the tooltips
				var tipz = new Tips($$('div.tooltipimg'),{
					className: 'tooltipbox',
					fixed: true,
					hideDelay: 0,
					showDelay: 0
				});
			});
		<?php 
        $script = ob_get_clean();
        if ((bool) $form->form_params->get('dynamic_files', 0) === false) {
            $document->addScriptDeclaration("//<![CDATA[" . "\n" . $script . "\n" . "//]]>");
        } else {
            //load the action class
            $form->loadActionHelper('load_js');
            $CfactionLoadJsHelper = new CfactionLoadJsHelper();
            $JSactiondata = new stdClass();
            $JSactiondata->content1 = $script;
            $JSParams = new JParameter('');
            $JSParams->set('dynamic_file', $form->form_params->get('dynamic_files', 0));
            $JSactiondata->params = $JSParams->toString();
            $CfactionLoadJsHelper->load($form, $JSactiondata);
        }
    }
Ejemplo n.º 28
0
 /**
  * Update the cached live site's URL for the front-end backup feature (altbackup.php)
  * and the detected Joomla! libraries path
  */
 public function updateMagicParameters()
 {
     $component =& JComponentHelper::getComponent('com_akeeba');
     if (is_object($component->params) && $component->params instanceof JRegistry) {
         $params = $component->params;
     } else {
         $params = new JParameter($component->params);
     }
     $params->set('siteurl', str_replace('/administrator', '', JURI::base()));
     if (defined('JPATH_LIBRARIES')) {
         $params->set('jlibrariesdir', AEUtilFilesystem::TranslateWinPath(JPATH_LIBRARIES));
     } elseif (defined("JPATH_PLATFORM")) {
         $params->set('jlibrariesdir', AEUtilFilesystem::TranslateWinPath(JPATH_PLATFORM));
     }
     if (AKEEBA_JVERSION == '16') {
         // Joomla! 1.6
         $joomla16 = true;
         $params->set('jversion', '1.6');
     } else {
         // Joomla! 1.5
         $joomla16 = false;
         $params->set('jversion', '1.5');
     }
     $db =& JFactory::getDBO();
     $data = $params->toString();
     if ($joomla16) {
         // Joomla! 1.6
         $sql = 'UPDATE `#__extensions` SET `params` = ' . $db->Quote($data) . ' WHERE ' . "`element` = 'com_akeeba' AND `type` = 'component'";
     } else {
         // Joomla! 1.5
         $sql = 'UPDATE `#__components` SET `params` = ' . $db->Quote($data) . ' WHERE ' . "`option` = 'com_akeeba' AND `parent` = 0 AND `menuid` = 0";
     }
     $db->setQuery($sql);
     $db->query();
 }
Ejemplo n.º 29
0
 function createMenuJ15($menu, $submenu)
 {
     jimport('joomla.utilities.string');
     jimport('joomla.application.component.helper');
     $config = KunenaFactory::getConfig();
     $component_id = JComponentHelper::getComponent('com_kunena')->id;
     // First fix all broken menu items
     $query = "UPDATE #__menu SET componentid={$this->db->quote($component_id)} WHERE type = 'component' AND link LIKE '%option=com_kunena%'";
     $this->db->setQuery($query);
     $this->db->query();
     if ($this->db->getErrorNum()) {
         throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
     }
     // Find out if menu exists
     $query = "SELECT id FROM `#__menu_types` WHERE `menutype`='kunenamenu';";
     $this->db->setQuery($query);
     $moduleid = (int) $this->db->loadResult();
     if ($this->db->getErrorNum()) {
         throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
     }
     // Do not touch existing menu
     if ($moduleid) {
         return;
     }
     // Create new Joomla menu for Kunena
     if (!$moduleid) {
         // Create a menu type for the Kunena menu
         $query = "REPLACE INTO `#__menu_types` (`id`, `menutype`, `title`, `description`) VALUES\n\t\t\t\t\t\t\t({$moduleid}, 'kunenamenu', {$this->db->Quote(JText::_('COM_KUNENA_MENU_TITLE'))} , {$this->db->Quote(JText::_('COM_KUNENA_MENU_TITLE_DESC'))} )";
         $this->db->setQuery($query);
         $this->db->query();
         if ($this->db->getErrorNum()) {
             throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
         }
     }
     // Forum
     $query = "SELECT id FROM `#__menu` WHERE `link`={$this->db->quote($menu['link'])} AND `menutype`='kunenamenu';";
     $this->db->setQuery($query);
     $parentid = (int) $this->db->loadResult();
     if ($this->db->getErrorNum()) {
         throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
     }
     if (!$parentid) {
         $params = new JParameter('');
         $params->bind($menu['params']);
         $query = "REPLACE INTO `#__menu` (`id`, `menutype`, `name`, `alias`, `link`, `type`, `published`, `parent`, `componentid`, `sublevel`, `ordering`, `checked_out`, `checked_out_time`, `pollid`, `browserNav`, `access`, `utaccess`, `params`, `lft`, `rgt`, `home`) VALUES\n\t\t\t\t\t\t\t({$parentid}, 'kunenamenu', {$this->db->quote($menu['name'])}, {$this->db->quote($menu['alias'])}, {$this->db->quote($menu['link'])}, 'component', 1, 0, {$component_id}, 0, 1, 0, '0000-00-00 00:00:00', 0, 0, {$menu['access']}, 0, {$this->db->quote($params->toString('INI'))}, 0, 0, 0);";
         $this->db->setQuery($query);
         $this->db->query();
         if ($this->db->getErrorNum()) {
             throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
         }
         $parentid = (int) $this->_db->insertId();
     }
     // Submenu (shown in Kunena)
     $defaultmenu = 0;
     $ordering = 0;
     foreach ($submenu as $menuitem) {
         $ordering++;
         //			$query = "SELECT id FROM `#__menu` WHERE `link`={$this->db->quote($menuitem['link'])} AND `menutype`='kunenamenu';";
         //			$this->db->setQuery ( $query );
         //			$id = ( int ) $this->db->loadResult ();
         //			if ($this->db->getErrorNum ())
         //				throw new KunenaInstallerException ( $this->db->getErrorMsg (), $this->db->getErrorNum () );
         $id = 0;
         if (!$id) {
             $params = new JParameter('');
             $params->bind($menuitem['params']);
             $query = "REPLACE INTO `#__menu` (`id`, `menutype`, `name`, `alias`, `link`, `type`, `published`, `parent`, `componentid`, `sublevel`, `ordering`, `checked_out`, `checked_out_time`, `pollid`, `browserNav`, `access`, `utaccess`, `params`, `lft`, `rgt`, `home`) VALUES\n\t\t\t\t\t\t\t\t({$id}, 'kunenamenu', {$this->db->quote($menuitem['name'])}, {$this->db->quote($menuitem['alias'])}, {$this->db->quote($menuitem['link'])},'component', 1, {$parentid}, {$component_id}, 1, {$ordering}, 0, '0000-00-00 00:00:00', 0, 0, {$menuitem['access']}, 0, {$this->db->quote($params->toString('INI'))}, 0, 0, 0);";
             $this->db->setQuery($query);
             $this->db->query();
             if ($this->db->getErrorNum()) {
                 throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
             }
             $id = (int) $this->_db->insertId();
             if (!$defaultmenu || isset($menuitem['default']) && $config->defaultpage == $menuitem['default']) {
                 $defaultmenu = $id;
             }
         }
     }
     if ($defaultmenu) {
         $query = "UPDATE `#__menu` SET `link`={$this->db->quote($menu['link'] . "&defaultmenu={$defaultmenu}")} WHERE id={$parentid}";
         $this->db->setQuery($query);
         $this->db->query();
         if ($this->db->getErrorNum()) {
             throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
         }
     }
     // Finally add forum menu link to default menu
     $jmenu = JMenu::getInstance('site');
     $dmenu = $jmenu->getDefault();
     $query = "SELECT id, name, type, link, published FROM `#__menu` WHERE `alias` IN ('forum', 'kunenaforum', {$this->db->quote(JText::_('COM_KUNENA_MENU_FORUM_ALIAS'))}) AND `menutype`={$this->db->quote($dmenu->menutype)}";
     $this->db->setQuery($query, 0, 1);
     $menualias = $this->db->loadObject();
     if ($this->db->getErrorNum()) {
         throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
     }
     // We do not want to replace users own menu items (just alias or deprecated link to Kunena)
     if (!$menualias || $menualias->type == 'menulink' || $menualias->link == 'index.php?option=com_kunena') {
         $id = $menualias ? intval($menualias->id) : 0;
         // Keep state (default=unpublished) and name (default=Forum)
         $published = $menualias ? intval($menualias->published) : 0;
         $name = $menualias ? $menualias->name : $menu['name'];
         $query = "REPLACE INTO `#__menu` (`id`, `menutype`, `name`, `alias`, `link`, `type`, `published`, `parent`, `componentid`, `sublevel`, `checked_out`, `checked_out_time`, `pollid`, `browserNav`, `access`, `utaccess`, `params`, `lft`, `rgt`, `home`) VALUES\n\t\t\t\t\t\t({$id}, {$this->db->quote($dmenu->menutype)}, {$this->db->quote($name)}, 'kunenaforum', 'index.php?Itemid={$parentid}', 'menulink', {$published}, 0, 0, 0, 0, '0000-00-00 00:00:00', 0, 0, {$menu['access']}, 0, 'menu_item={$parentid}{$menu['params']}\r\n\r\n', 0, 0, 0);";
         $this->db->setQuery($query);
         $this->db->query();
         if ($this->db->getErrorNum()) {
             throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum());
         }
     }
 }
Ejemplo n.º 30
0
 public function save()
 {
     $enableSRP = $this->input->get('srp', 0, 'bool');
     $enableAutoupdate = $this->input->get('autoupdate', 0, 'bool');
     $runConfwiz = $this->input->get('confwiz', 0, 'bool');
     $angieupgrade = $this->input->get('angieupgrade', 0, 'bool');
     $minStability = $this->input->get('minstability', 'stable', 'cmd');
     $acceptlicense = $this->input->get('acceptlicense', 0, 'bool');
     $acceptsupport = $this->input->get('acceptsupport', 0, 'bool');
     $acceptbackuptest = $this->input->get('acceptbackuptest', 0, 'bool');
     if (!in_array($minStability, array('alpha', 'beta', 'rc', 'stable'))) {
         $minStability = 'stable';
     }
     // SRP is only supported on MySQL databases
     if (!$this->isMySQL()) {
         $enableSRP = false;
     }
     $db = JFactory::getDBO();
     if ($enableSRP) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('srp'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     } else {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('srp'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     }
     if ($enableAutoupdate) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('oneclickaction'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('akeebaupdatecheck'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     } else {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('oneclickaction'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('akeebaupdatecheck'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     }
     if ($angieupgrade) {
         $this->_angieUpgrade();
     }
     // Update last version check and minstability. DO NOT USE JCOMPONENTHELPER!
     $sql = $db->getQuery(true)->select($db->qn('params'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q('com_akeeba'));
     $db->setQuery($sql);
     $rawparams = $db->loadResult();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $params = new JRegistry();
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $params->loadString($rawparams);
         } else {
             $params->loadJSON($rawparams);
         }
     } else {
         $params = new JParameter($rawparams);
     }
     if ($acceptlicense && $acceptsupport) {
         $version = AKEEBA_VERSION;
     } else {
         $version = '0.0.0';
     }
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $params->set('lastversion', $version);
         $params->set('minstability', $minStability);
         $params->set('acceptlicense', $acceptlicense);
         $params->set('acceptsupport', $acceptsupport);
         $params->set('acceptbackuptest', $acceptbackuptest);
         $params->set('angieupgrade', $angieupgrade ? 1 : 0);
     } else {
         $params->setValue('lastversion', $version);
         $params->setValue('minstability', $minStability);
         $params->setValue('acceptlicense', $acceptlicense);
         $params->setValue('acceptsupport', $acceptsupport);
         $params->setValue('acceptbackuptest', $acceptbackuptest);
         $params->setValue('angieupgrade', $angieupgrade ? 1 : 0);
     }
     $data = $params->toString('JSON');
     $sql = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($data))->where($db->qn('element') . ' = ' . $db->q('com_akeeba'))->where($db->qn('type') . ' = ' . $db->q('component'));
     $db->setQuery($sql);
     $db->execute();
     // Even better, create the "akeeba.lastversion.php" file with this information
     $fileData = "<" . "?php\ndefined('_JEXEC') or die();\ndefine('AKEEBA_LASTVERSIONCHECK','" . $version . "');";
     JLoader::import('joomla.filesystem.file');
     $fileName = JPATH_COMPONENT_ADMINISTRATOR . '/akeeba.lastversion.php';
     JFile::write($fileName, $fileData);
     // Force reload the Live Update information
     if ($version != '0.0.0') {
         $dummy = LiveUpdate::getUpdateInformation(true);
     }
     // Run the configuration wizard if requested
     $message = '';
     if ($runConfwiz) {
         $url = 'index.php?option=com_akeeba&view=confwiz';
     } else {
         $url = 'index.php?option=com_akeeba&view=cpanel';
     }
     if (!$acceptlicense) {
         JFactory::getApplication()->enqueueMessage(JText::_('AKEEBA_POSTSETUP_ERR_ACCEPTLICENSE'), 'error');
         $url = 'index.php?option=com_akeeba&view=postsetup';
     }
     if (!$acceptsupport) {
         JFactory::getApplication()->enqueueMessage(JText::_('AKEEBA_POSTSETUP_ERR_ACCEPTSUPPORT'), 'error');
         $url = 'index.php?option=com_akeeba&view=postsetup';
     }
     if (!$acceptbackuptest) {
         JFactory::getApplication()->enqueueMessage(JText::_('AKEEBA_POSTSETUP_ERR_ACCEPTBACKUPTEST'), 'error');
         $url = 'index.php?option=com_akeeba&view=postsetup';
     }
     JFactory::getApplication()->redirect($url);
 }