Example #1
0
 /**
  * This checks for the correct Help Version.
  *
  * @param	string	$release	Joomla release number
  * @param	string	$expect		Expected help Version
  * @param	string	$message	Test failure message
  *
  * @return void
  * @dataProvider casesHelp
  */
 public function testGetHelpVersion($release, $expect, $message)
 {
     if (is_null($release)) {
         $output = $this->object->getHelpVersion();
     } else {
         $this->object->RELEASE = '1.0';
         $output = $this->object->getHelpVersion();
     }
     $this->assertEquals($expect, $output, $message);
 }
Example #2
0
 /**
  * Create an URL for a giving help file reference
  *
  * @param string The name of the popup file (excluding the file extension for an xml file)
  * @param boolean Use the help file in the component directory
  */
 static function createURL($ref, $useComponent = false)
 {
     $component = JApplicationHelper::getComponentName();
     $app =& JFactory::getApplication();
     $user =& JFactory::getUser();
     $userHelpUrl = $user->getParam('helpsite');
     $globalHelpUrl = $app->getCfg('helpurl');
     $lang =& JFactory::getLanguage();
     if ($useComponent) {
         if (!preg_match('#\\.html$#i', $ref)) {
             $ref = $ref . '.html';
         }
         $url = 'components/' . $component . '/help';
         $tag = $lang->getTag();
         // Check if the file exists within a different language!
         if ($lang->getTag() != 'en-GB') {
             $localeURL = JPATH_BASE . DS . $url . DS . $tag . DS . $ref;
             jimport('joomla.filesystem.file');
             if (!JFile::exists($localeURL)) {
                 $tag = 'en-GB';
             }
         }
         return $url . '/' . $tag . '/' . $ref;
     }
     if ($userHelpUrl) {
         // Online help site as defined in GC
         $version = new JVersion();
         $ref .= $version->getHelpVersion();
         $url = $userHelpUrl . '/index2.php?option=com_content&task=findkey&tmpl=component&keyref=' . urlencode($ref);
     } else {
         if ($globalHelpUrl) {
             // Online help site as defined in GC
             $version = new JVersion();
             $ref .= $version->getHelpVersion();
             $url = $globalHelpUrl . '/index2.php?option=com_content&task=findkey&tmpl=component;1&keyref=' . urlencode($ref);
         } else {
             // Included html help files
             $helpURL = 'help/' . $lang->getTag() . '/';
             if (!eregi('\\.html$', $ref)) {
                 $ref = $ref . '.html';
             }
             // Check if the file exists within a different language!
             if ($lang->getTag() != 'en-GB') {
                 $localeURL = JPATH_BASE . $helpURL . $ref;
                 jimport('joomla.filesystem.file');
                 if (!JFile::exists($localeURL)) {
                     $helpURL = 'help/en-GB/';
                 }
             }
             $url = $helpURL . $ref;
         }
     }
     return $url;
 }
Example #3
0
 public function __construct()
 {
     parent::__construct();
     // Only process this if task != azrul_ajax
     $task = JRequest::getCmd('task', '');
     $document = JFactory::getDocument();
     if ($document instanceof JDocumentHTML) {
         $app = JFactory::getApplication();
         $template = $app->getTemplate();
         // Add some javascript that may be needed
         // Add some javascript that may be needed
         if ($task != 'azrul_ajax') {
             $version = new JVersion();
             if ($version->getHelpVersion() <= '0.25') {
                 // load jquery if joomla 2.5.x
                 $document->addScript(COMMUNITY_ASSETS_URL . '/js/jquery.min.js');
                 $document->addScript(COMMUNITY_ASSETS_URL . '/js/bootstrap.min.js');
                 $document->addScript(COMMUNITY_ASSETS_URL . '/js/joomla25.min.js');
                 // load css if joomla 2.5.x
                 $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/joomla25.css');
             }
             //$document->addScript( COMMUNITY_ASSETS_URL . '/js/jquery.min.js' );
             //$document->addScript( COMMUNITY_ASSETS_URL . '/js/bootstrap.min.js' );
             //$document->addScript( COMMUNITY_ASSETS_URL . '/js/ace-elements.min.js' );
             //$document->addScript( COMMUNITY_ASSETS_URL . '/js/ace.min.js' );
             //dont load in installer
             if (JRequest::getCmd('view', 'community') !== 'installer') {
                 require_once JPATH_COMPONENT . '/helpers/community.php';
             }
         }
         $document->addScript(COMMUNITY_ASSETS_URL . '/admin.js');
         $document->addScript(JURI::root() . 'components/com_community/assets/window-1.0.js');
         $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/bootstrap.min.css');
         $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/font-awesome.min.css');
         $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/ace-fonts.css');
         $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/ace.min.css');
         $document->addStyleSheet(COMMUNITY_ASSETS_URL . '/css/fullcalendar.css');
     }
 }
Example #4
0
 /**
  * Get application-specific suffixes to use with template paths. This allows
  * you to look for view template overrides based on the application version.
  *
  * @return  array  A plain array of suffixes to try in template names
  */
 public function getTemplateSuffixes()
 {
     $jversion = new \JVersion();
     $versionParts = explode('.', $jversion->RELEASE);
     $majorVersion = array_shift($versionParts);
     $suffixes = array('.j' . str_replace('.', '', $jversion->getHelpVersion()), '.j' . $majorVersion);
     return $suffixes;
 }
Example #5
0
    public function __construct()
    {
        parent::__construct();
        if (defined('ZE_USERINFO_JUST_ADDED')) {
            return;
        }
        define('ZE_USERINFO_JUST_ADDED', true);
        $doc = JFactory::getDocument();
        $doc->addStyleSheet(JURI::root() . 'plugins/user/zygo_profile/fields/userinfo.css');
        $doc->addScript(JURI::root() . 'plugins/user/zygo_profile/fields/drag.js');
        //$doc->addStyleSheet(JURI::root().'plugins/user/zygo_profile/fields/drag.css');
        $version = new JVersion();
        $Jversion = (int) substr($version->getHelpVersion(), 1);
        $Jversion = $Jversion >= 30 ? 30 : ($Jversion >= 16 ? 16 : 15);
        $disabled_options = $this->disabled_options();
        $disabledJS = array();
        foreach ($disabled_options as $name => $value) {
            if (is_string($value)) {
                $disabledJS[] = $name . ': "' . $value . '"';
            } else {
                $disabledJSC = $name . ': {';
                foreach ($value as $k => $val) {
                    if ($k) {
                        $disabledJSC .= ', ';
                    }
                    $disabledJSC .= $val . ': true';
                }
                $disabledJSC .= '}';
                $disabledJS[] = $disabledJSC;
            }
        }
        $disabledJSString = 'var ZEdisabledJS = {' . implode(', ', $disabledJS) . '}; ';
        $addSelectCorrection = '';
        if ($Jversion == 30) {
            $addSelectCorrection = '

				newTab.getElements("select").setStyles({"display":"block"});
				newTab.getElements(".chzn-container").destroy();

				jQuery("select", newTab).removeClass("chzn-done").chosen({
						disable_search_threshold : 10,
						allow_single_deselect : true
					});';
        }
        $doc->addScriptDeclaration($disabledJSString . '
			window.addEvent("domready", function() {
				prop={};

				var wrapperLis=$$(".userinfo_wrapper")[0].getParent().getParent().getChildren("li");

				wrapperLis.each(function(el, i){
					if(!el.getChildren(".userinfo_wrapper")[0]){
						oddEven=(i%2)? "odd" : "even";
						el.addClass("zeLiWrap "+oddEven);
						var zdiv=document.createElement("div");
						zdiv.className="zeClear";
						el.appendChild(zdiv);
					}
				});


		      list2 = document.getElementById("userinfo_tab_ul_userinfo");
		      if(list2){
			      ZDragDrop.makeListContainer( list2 );
			      list2.onZDragOver = function() { this.style["border"] = "1px dashed #8E0B8C"; this.style["background"] = "#FFF"; };
			      list2.onZDragOut = function() {this.style["border"] = "1px solid transparent"; this.style["background"] = "none";};
		      }

			});
			function zeOpenClose(e, self){
				var target = e.srcElement || e.target;
				target = $(target);
				self = $(self);
				if(!target.hasClass("zeOpenCloseSpan") && !target.hasClass("userinfo_tab_head")) return;

				if(self.hasClass("zeOpened")){
					self.removeClass("zeOpened");
				}else{
					self.addClass("zeOpened");
				}
			}
			function zeFieldCheck(self, checkedEl){
				fieldname=self.getAttribute("rel");

				$$(".zeFieldCheck_"+fieldname).removeClass("checked");
				if(self.hasClass("checked")){
					self.removeClass("checked");
				}else{
					self.addClass("checked");
				}
				$("jform_params_"+fieldname+"activeTab").value=checkedEl;
			}
			function zeRemove(self){
				self.parentNode.parentNode.destroy();
			}

			var ZE_NUM_ALL=[];
			function zeAddNew(fieldname){
				ZE_NUM=ZE_NUM_ALL[fieldname];

				var newTab = document.createElement("li");
				newTab.id="userinfo_tab_"+fieldname+"_"+ZE_NUM;
				newTab.className="userinfo_tab";
				var inner = $("userinfo_tab_"+fieldname+"_0").innerHTML;

				inner = inner.replace(/_ze_new_set_label_/g, ZE_NUM);

				inner = inner.replace(/jform\\[params\\]\\[(\\w*)\\]\\[(\\w*)\\]\\[0\\]/g, "jform[params][$1][$2]["+ZE_NUM+"]");
				inner = inner.replace(/jform\\[params\\]\\[(\\w*)\\]\\[(\\w*)\\]\\[(\\w*)\\]\\[0\\]/g, "jform[params][$1][$2][$3]["+ZE_NUM+"]");
				inner = inner.replace(/jform_params_(\\w*)0/g, "jform_params_$1"+ZE_NUM);
				inner = inner.replace(/jformparams(\\w*)0/g, "jformparams$1"+ZE_NUM);

				inner = inner.replace(/value=\\"uniqueID0\\"/g, \'value="uniqueID\'+ZE_NUM+\'"\');
				inner = inner.replace(/value=\\"' . JText::_('PLG_USER_ZYGO_PROFILE_ADD_NEW_FIELD') . '0\\"/g, \'value="' . JText::_('PLG_USER_ZYGO_PROFILE_ADD_NEW_FIELD') . '\'+ZE_NUM+\'"\');

				inner = inner.replace(/zeUniqueIdLabel(\\w*)0/g, "zeUniqueIdLabel$1"+ZE_NUM);

				//inner = inner.replace(/onclick=\\"zeFieldCheck\\(this, 0\\)\\"/g, "onclick=\\"zeFieldCheck(this, "+ZE_NUM+")\\"");
				inner = inner.replace(/onchange=\\"ze_show_hide_block_types\\(this, \'(\\w*)\', \'(\\w*)\', 0\\)\\"/g, "onchange=\\"ze_show_hide_block_types(this, \'$1\', \'$2\', "+ZE_NUM+")\\"");

				inner = inner.replace(/onclick=\\"zeAllowDisableColor\\(this, \'(\\w*)\', \'(\\w*)\', 0\\)\\"/g, "onclick=\\"zeAllowDisableColor(this, \'$1\', \'$2\', "+ZE_NUM+")\\"");

				inner = inner.replace(/ze_block_show_hide(\\w*)0/g, "ze_block_show_hide$1"+ZE_NUM);

				//inner = inner.replace(/zeFieldCheck_(\\w*)0/g, "zeFieldCheck_$1"+ZE_NUM);

				inner = inner.replace(/userinfo_tab_0/g, "userinfo_tab_"+ZE_NUM);

				inner = inner.replace(/zeShowHideSelectOptions\\(this, \'0\'/g, "zeShowHideSelectOptions(this, \'"+ZE_NUM+"\'");
				inner = inner.replace(/sh_addField\\(this, \'0\'/g, "sh_addField(this, \'"+ZE_NUM+"\'");

				inner = inner.replace(/zeShowHideSelectOptions\\(this, \'0\'/g, "zeShowHideSelectOptions(this, \'"+ZE_NUM+"\'");

				inner = inner.replace(/id=\\"zeLiParam(\\w*)0\\"/g, "id=\\"zeLiParam$1"+ZE_NUM+"\\"");

				inner = inner.replace("<span class=\\"zygoid\\">0</span>", "<span class=\\"zygoid\\">"+ZE_NUM+"</span>");

				newTab.innerHTML=inner;
				$("userinfo_tab_ul_"+fieldname).appendChild(newTab);


				var labelTooltip=$("zeUniqueIdLabel"+fieldname+ZE_NUM);
				var parts = labelTooltip.get("title").split("::", 2);
				labelTooltip.store("tip:title", parts[0]);
				labelTooltip.store("tip:text", parts[1]);
				new Tips(labelTooltip, { maxTitleChars: 50, fixed: false});

				/*var labelTooltip2=$("zeFieldCheck_"+fieldname+ZE_NUM);
				var parts = labelTooltip2.get("title").split("::", 2);
				labelTooltip2.store("tip:title", parts[0]);
				labelTooltip2.store("tip:text", parts[1]);
				new Tips(labelTooltip2, { maxTitleChars: 50, fixed: false});*/

				ZE_NUM++;
 ZE_NUM_ALL[fieldname]=ZE_NUM;

				ZDragDrop.makeItemZDragable(newTab);

				' . $addSelectCorrection . '
			}

			function ze_show_hide_block_types(self, fieldname, name, num){

				$$(".ze_block_show_hide"+fieldname+name+num).hide();
				$("jformparams"+fieldname+name+self.value+num).show();

				Object.each(ZEdisabledJS, function(type, elemName){
					if(type == self.value || ((typeof(type)=="object") && (self.value in type))){
						$("zeLiParam"+fieldname+elemName+num).hide();
					}else{
						$("zeLiParam"+fieldname+elemName+num).show();
					}
				});
			}
			function zeAllowDisableColor(self, fieldname, name, num){
				$("jform_params_"+fieldname+name+num).readOnly = (self.checked)? false : true;
			}
			function sh_addField(self, num, fieldname, name){

				    wrapdiv=document.createElement("div");
				    wrapdiv.innerHTML=\'<div><input type="text" name="jform[params][\'+fieldname+\'][\'+name+\'_value][\'+num+\'][]" value="" /><input type="text" name="jform[params][\'+fieldname+\'][\'+name+\'_text][\'+num+\'][]" value="" /><input type="button" class="button buttonminus btn btn-danger" onclick="this.parentNode.parentNode.removeChild(this.parentNode)" value="-"></div>\';
				    document.getElementById("shfield_multitext_wrapper_jform_params_"+fieldname+name+num).appendChild(wrapdiv);
			}
			function zeShowHideSelectOptions(self, num, fieldname, name){
				document.getElementById("zeLiParam"+fieldname+"fieldOptions"+num).style.display =
				(self.value=="select" || self.value=="multiselect" || self.value=="radio" || self.value=="checkboxes") ? "block" : "none";
                
                var fdv = document.getElementById("zeLiParam"+fieldname+"fieldDefaultValue"+num);

				fdv.style.display = (self.value!="html") ? "block" : "none";

				document.getElementById("zeLilabel"+fieldname+"fieldParams"+num).innerHTML =
				(fdv.value!="html") ? "' . JText::_("PLG_USER_ZYGO_PROFILE_FIELDGROUP_FIELDPARAMS_HTML") . '" : "' . JText::_("PLG_USER_ZYGO_PROFILE_FIELDGROUP_FIELDPARAMS") . '";

			}
		');
    }
Example #6
0
 public function enablePlugin($plugin)
 {
     $db = JFactory::getDBO();
     $version = new JVersion();
     $joomla_ver = $version->getHelpVersion();
     $query = 'UPDATE ' . $db->quoteName('#__extensions') . ' SET ' . $db->quoteName('enabled') . ' = ' . $db->quote(1) . ' WHERE ' . $db->quoteName('element') . ' = ' . $db->quote($plugin);
     $db->setQuery($query);
     if (!$db->query()) {
         return $db->getErrorNum() . ':' . $db->getErrorMsg();
     } else {
         return null;
     }
 }
Example #7
0
 function enablePlugin($plugin)
 {
     $db =& JFactory::getDBO();
     $version = new JVersion();
     $joomla_ver = $version->getHelpVersion();
     //Joomla version 1.5 above
     if ($joomla_ver <= '0.15') {
         $query = 'UPDATE ' . $db->nameQuote('#__plugins') . ' SET ' . $db->nameQuote('published') . ' = ' . $db->quote(1) . ' WHERE ' . $db->nameQuote('element') . ' = ' . $db->quote($plugin);
     } elseif ($joomla_ver >= '0.16') {
         //Joomla version 1.6 and later
         $query = 'UPDATE ' . $db->nameQuote('#__extensions') . ' SET ' . $db->nameQuote('enabled') . ' = ' . $db->quote(1) . ' WHERE ' . $db->nameQuote('element') . ' = ' . $db->quote($plugin);
     }
     $db->setQuery($query);
     if (!$db->query()) {
         return $db->getErrorNum() . ':' . $db->getErrorMsg();
     } else {
         return null;
     }
 }
Example #8
0
 public function getRssFeed($url, $id)
 {
     $response = new JAXResponse();
     $version = new JVersion();
     $joomla_ver = $version->getHelpVersion();
     $rss = array();
     if ($joomla_ver <= '0.30') {
         $rssData = $this->getRSS($url, $id);
         foreach ($rssData->items as $item) {
             $data = new stdClass();
             preg_match_all('#(<[/]?img.*>)#U', $item->get_content(), $matches);
             $imgSrc = '';
             if (isset($matches[0][0])) {
                 $imgSrc = explode('src="', $matches[0][0]);
                 $imgSrc = explode('" ', $imgSrc[1]);
                 $imgSrc = $imgSrc[0];
             }
             $data->title = $item->get_title();
             $data->url = $item->get_link();
             $data->img = $imgSrc;
             $data->published = strtolower($item->get_date('l , d F Y'));
             $data->content = strip_tags(JFilterOutput::stripImages($item->get_description()));
             $rss[] = $data;
         }
     } else {
         try {
             $feed = new JFeedFactory();
             $rssDoc = $feed->getFeed($url);
         } catch (InvalidArgumentException $e) {
             return JText::_('MOD_FEED_ERR_FEED_NOT_RETRIEVED');
         } catch (RunTimeException $e) {
             return JText::_('MOD_FEED_ERR_FEED_NOT_RETRIEVED');
         } catch (LogicException $e) {
             return JText::_('MOD_FEED_ERR_FEED_NOT_RETRIEVED');
         }
         if (empty($rssDoc)) {
             return JText::_('MOD_FEED_ERR_FEED_NOT_RETRIEVED');
         }
         if ($rssDoc) {
             for ($i = 0; $i < 5; $i++) {
                 $date = $rssDoc[$i]->publishedDate;
                 $data = new stdClass();
                 preg_match_all('#(<[/]?img.*>)#U', $rssDoc[$i]->content, $matches);
                 $imgSrc = '';
                 if (isset($matches[0][0])) {
                     $imgSrc = explode('src="', $matches[0][0]);
                     $imgSrc = explode('" ', $imgSrc[1]);
                     $imgSrc = $imgSrc[0];
                 }
                 $data->title = $rssDoc[$i]->title;
                 $data->url = $rssDoc[$i]->uri;
                 $data->img = $imgSrc;
                 $data->published = strtolower($date->format('l , d F Y'));
                 $data->content = strip_tags(JFilterOutput::stripImages($rssDoc[$i]->content));
                 $rss[] = $data;
             }
         }
     }
     $html = '';
     foreach ($rss as $data) {
         //var_dump($data->img);
         $html .= '<div class="media clearfix">';
         $html .= '<div class="media-body">';
         $html .= '<h4 class="media-heading reset-gap"><a href="' . $data->url . '" target="_blank">' . $data->title . '</a></h4>';
         $html .= '<p class="orange">' . $data->published . '</p>';
         if ($data->img) {
             $html .= '<a class="pull-left thumbnail" href="' . $data->url . '" target="_blank">';
             $html .= '<img class="media-object" src="' . $data->img . '" width="100px"  />';
             $html .= '</a>';
         }
         $html .= JHTML::_('string.truncate', $data->content, 200);
         $html .= '</div>';
         $html .= '</div>';
     }
     $response->addScriptCall('joms.jQuery("#' . $id . '").html', $html);
     return $response->sendResponse();
 }
Example #9
0
 /**
  * Tests the getHelpVersion method
  *
  * @return  void
  *
  * @since   3.0
  */
 public function testGetHelpVersion()
 {
     $this->assertInternalType('string', $this->object->getHelpVersion());
 }
Example #10
0
<?php

/**
* @copyright (C) 2013 iJoomla, Inc. - All rights reserved.
* @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html)
* @author iJoomla.com <*****@*****.**>
* @url https://www.jomsocial.com/license-agreement
* The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
* More info at https://www.jomsocial.com/license-agreement
*/
// Disallow direct access to this file
defined('_JEXEC') or die('Restricted access');
define('COMMUNITY_ASSETS_PATH', JPATH_COMPONENT . '/assets');
define('COMMUNITY_ASSETS_URL', JURI::base() . 'components/com_community/assets');
define('COMMUNITY_BASE_PATH', dirname(JPATH_BASE) . '/components/com_community');
define('COMMUNITY_BASE_ASSETS_PATH', JPATH_BASE . '/components/com_community/assets');
define('COMMUNITY_BASE_ASSETS_URL', JURI::root() . 'components/com_community/assets');
define('COMMUNITY_CONTROLLERS', JPATH_COMPONENT . '/controllers');
// @TODO to be removed.
jimport('joomla.version');
$version = new JVersion();
$joomla_ver = $version->getHelpVersion();
// @ENDTODO
Example #11
0
 /**
  * Tests the getHelpVersion method
  *
  * @return  void
  *
  * @since   3.0
  *
  * @covers  JVersion::getHelpVersion
  */
 public function testGetHelpVersion()
 {
     $this->assertThat($this->object->getHelpVersion(), $this->isType('string'), 'getHelpVersion should return a string with the version.');
 }
Example #12
0
 /**
  * Save controller that receives arguments via HTTP POST.
  **/
 public function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $lang =& JFactory::getLanguage();
     $lang->load('com_users');
     $userId = JRequest::getVar('userid', '', 'POST');
     $mainframe =& JFactory::getApplication();
     $message = '';
     $url = JRoute::_('index.php?option=com_community&view=users', false);
     $my =& JFactory::getUser();
     $acl =& JFactory::getACL();
     $cacl =& CACL::getInstance();
     $mailFrom = $mainframe->getCfg('mailfrom');
     $fromName = $mainframe->getCfg('fromname');
     $siteName = $mainframe->getCfg('sitename');
     if (empty($userId)) {
         $message = JText::_('COM_COMMUNITY_USERS_EMPTY_USER_ID');
         $mainframe->redirect($url, $message);
     }
     // Create a new JUser object
     $user = new JUser($userId);
     $original_gid = $user->get('gid');
     $post = JRequest::get('post');
     $post['username'] = JRequest::getVar('username', '', 'post', 'username');
     $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $notifyEmailSystem = JRequest::getVar('sendEmail', '', 'post', 'sendEmail');
     if (!$user->bind($post)) {
         $message = JText::_('COM_COMMUNITY_USERS_SAVE_USER_INFORMATION_ERROR') . ' : ' . $user->getError();
         $url = JRoute::_('index.php?option=com_community&view=users&layout=edit&id=' . $userId, false);
         $mainframe->redirect($url, $message);
         exit;
     }
     //$objectID 	= $acl->get_object_id( 'users', $user->get('id'), 'ARO' );
     //$groups 	= $acl->get_object_groups( $objectID, 'ARO' );
     //$this_group = JString::strtolower( $acl->get_group_name( $groups[0], 'ARO' ) );
     $this_group = $cacl->getGroupsByUserId($user->get('id'));
     if ($user->get('id') == $my->get('id') && $user->get('block') == 1) {
         $message = JText::_('COM_COMMUNITY_USERS_BLOCK_YOURSELF');
         $url = JRoute::_('index.php?option=com_community&view=users&layout=edit&id=' . $userId, false);
         $mainframe->redirect($url, $message);
         exit;
     }
     if ($this_group == 'super administrator' && $user->get('block') == 1) {
         $message = JText::_('COM_COMMUNITY_USERS_BLOCK_SUPER_ADMINISTRATOR');
         $url = JRoute::_('index.php?option=com_community&view=users&layout=edit&id=' . $userId, false);
         $mainframe->redirect($url, $message);
         exit;
     }
     if ($this_group == 'administrator' && $my->get('gid') == 24 && $user->get('block') == 1) {
         $message = JText::_('COM_COMMUNITY_USERS_WARNBLOCK');
         $url = JRoute::_('index.php?option=com_community&view=users&layout=edit&id=' . $userId, false);
         $mainframe->redirect($url, $message);
         exit;
     }
     if ($this_group == 'super administrator' && $my->get('gid') != 25) {
         $message = JText::_('COM_COMMUNITY_USERS_SUPER_ADMINISTRATOR_EDIT');
         $url = JRoute::_('index.php?option=com_community&view=users&layout=edit&id=' . $userId, false);
         $mainframe->redirect($url, $message);
         exit;
     }
     $isNew = $user->get('id') == 0;
     if (!$isNew) {
         if ($user->get('gid') != $original_gid && $original_gid == 25) {
             $query = 'SELECT COUNT( ' . $db->nameQuote('id') . ' )' . ' FROM ' . $db->nameQuote('#__users') . ' WHERE ' . $db->nameQuote('gid') . ' = ' . $db->Quote(25) . ' AND ' . $db->nameQuote('block') . ' = ' . $db->Quote(0);
             $db->setQuery($query);
             $count = $db->loadResult();
             if ($count <= 1) {
                 $message = JText::_('COM_COMMUNITY_USERS_WARN_ONLY_SUPER');
                 $url = JRoute::_('index.php?option=com_community&view=users&layout=edit&id=' . $userId, false);
                 $mainframe->redirect($url, $message);
                 exit;
             }
         }
     }
     //Joomla 1.6 patch to keep the group ID of user intact when saving
     if (property_exists($user, 'groups')) {
         foreach ($user->groups as $groupid => $groupname) {
             $user->groups[$groupid] = $groupid;
         }
     }
     if (!$user->save()) {
         $message = JText::_('COM_COMMUNITY_USERS_SAVE_USER_INFORMATION_ERROR') . ' : ' . $user->getError();
         $mainframe->redirect($url, $message);
         exit;
     }
     $appsLib =& CAppPlugins::getInstance();
     $appsLib->loadApplications();
     $userRow = array();
     $userRow[] = $user;
     $appsLib->triggerEvent('onUserDetailsUpdate', $userRow);
     // @rule: Send out email if it is a new user.
     if ($isNew) {
         $adminEmail = $my->get('email');
         $adminName = $my->get('name');
         $subject = JText::_('COM_COMMUNITY_USERS_NEW_USER_MESSAGE_SUBJECT');
         $message = sprintf(JText::_('COM_COMMUNITY_USERS_NEW_USER_MESSAGE'), $user->get('name'), $siteName, JURI::root(), $user->get('username'), $user->password_clear);
         if (!empty($mailfrom) && !empty($fromName)) {
             $adminName = $fromName;
             $adminEmail = $mailFrom;
         }
         JUtility::sendMail($adminEmail, $adminName, $user->get('email'), $subject, $message);
     }
     // If updating self, load the new user object into the session
     if ($user->get('id') == $my->get('id')) {
         jimport('joomla.version');
         $version = new JVersion();
         $joomla_ver = $version->getHelpVersion();
         // Get the user group from the ACL
         if ($joomla_ver <= '0.15') {
             $grp = $acl->getAroGroup($user->get('id'));
             // Mark the user as logged in
             $user->set('guest', 0);
             $user->set('aid', 1);
             // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
             if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) {
                 $user->set('aid', 2);
             }
             // Set the usertype based on the ACL group name
             $user->set('usertype', $grp->name);
         } elseif ($joomla_ver >= '0.16') {
             $grp_name = $cacl->getGroupUser($user->get('id'));
             // Mark the user as logged in
             $user->set('guest', 0);
             $user->set('aid', 1);
             // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
             if ($cacl->is_group_child_of($grp_name, 'Registered') || $cacl->is_group_child_of($grp_name, 'Public Backend')) {
                 $user->set('aid', 2);
             }
             // Set the usertype based on the ACL group name
             $user->set('usertype', $grp_name);
         }
         $session =& JFactory::getSession();
         $session->set('user', $user);
     }
     // Process and save custom fields
     $user = CFactory::getUser($userId);
     $model =& $this->getModel('users');
     $userModel = CFactory::getModel('profile');
     $values = array();
     $profile = $userModel->getEditableProfile($userId, $user->getProfileType());
     CFactory::load('libraries', 'profile');
     foreach ($profile['fields'] as $group => $fields) {
         foreach ($fields as $data) {
             // Get value from posted data and map it to the field.
             // Here we need to prepend the 'field' before the id because in the form, the 'field' is prepended to the id.
             $postData = JRequest::getVar('field' . $data['id'], '', 'POST');
             $values[$data['id']] = CProfileLibrary::formatData($data['type'], $postData);
             // @rule: Validate custom profile if necessary
             if (!CProfileLibrary::validateField($data['id'], $data['type'], $values[$data['id']], $data['required'])) {
                 // If there are errors on the form, display to the user.
                 $message = JText::sprintf('The field "%1$s" contain improper values', $data['name']);
                 $mainframe->redirect('index.php?option=com_community&view=users&layout=edit&id=' . $user->id, $message, 'error');
                 return;
             }
         }
     }
     // Update user's parameter DST
     $params =& $user->getParams();
     $offset = $post['daylightsavingoffset'];
     $params->set('daylightsavingoffset', $offset);
     $params->set('notifyEmailSystem', $notifyEmailSystem);
     // Update user's point
     $points = JRequest::getVar('userpoint', '', 'REQUEST');
     if (!empty($points)) {
         $user->_points = $points;
         $user->save();
     }
     // Update user's status
     if ($user->getStatus() != $post['status']) {
         $user->setStatus($post['status']);
     }
     $user->save('params');
     $valuesCode = array();
     foreach ($values as $key => &$val) {
         $fieldCode = $userModel->getFieldCode($key);
         if ($fieldCode) {
             $valuesCode[$fieldCode] =& $val;
         }
     }
     // Trigger before onBeforeUserProfileUpdate
     $args = array();
     $args[] = $userId;
     $args[] = $valuesCode;
     $saveSuccess = false;
     $result = $appsLib->triggerEvent('onBeforeProfileUpdate', $args);
     if (!$result || !in_array(false, $result)) {
         $saveSuccess = true;
         $userModel->saveProfile($userId, $values);
     }
     // Trigger before onAfterUserProfileUpdate
     $args = array();
     $args[] = $userId;
     $args[] = $saveSuccess;
     $result = $appsLib->triggerEvent('onAfterProfileUpdate', $args);
     if (!$saveSuccess) {
         $message = JText::_('COM_COMMUNITY_USERS_PROFILE_NOT_UPDATED');
         $mainframe->redirect($url, $message, 'error');
     }
     $message = JText::_('COM_COMMUNITY_USERS_UPDATED_SUCCESSFULLY');
     $mainframe->redirect($url, $message);
 }
Example #13
0
</div>
    <div id="progress-status" style="padding-top: 5px;"></div>
</fieldset>
</div>
</form>

<script>
    jQuery("#toolbar-save").prependTo(".send-message-wrapper");
    var click = jQuery("#toolbar-save button").attr('onclick');
    click +=';return false;';
    jQuery("#toolbar-save button").attr('onclick',click);
</script>

<?php 
$version = new JVersion();
if ($version->getHelpVersion() <= '0.25') {
    ?>

    <script>
        jQuery("#toolbar-save").prependTo(".send-message-wrapper");
        jQuery("#toolbar-save").replaceWith(function() {
            return jQuery("<div />", {html: jQuery(this).html()});
        });
        jQuery(".send-message-wrapper span").addClass('icon-save');
        jQuery(".send-message-wrapper a").addClass('btn btn-success btn-small');
    </script>

    <?php 
} else {
    ?>
Example #14
0
 /**
  * Guesses the best candidate for the path to use for a particular form.
  *
  * @param   string  $source  The name of the form file to load, without the .xml extension
  *
  * @return  string  The path and filename of the form to load
  *
  * @since   2.0
  */
 public function findFormFilename($source)
 {
     // Get some useful variables
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     $option = $this->input->getCmd('option', 'com_foobar');
     $view = $this->input->getCmd('view', 'cpanels');
     if (!$isCli) {
         $template = JFactory::getApplication()->getTemplate();
     } else {
         $template = 'cli';
     }
     $file_root = $isAdmin ? JPATH_ADMINISTRATOR : JPATH_SITE;
     $file_root .= '/components/' . $option;
     $alt_file_root = $isAdmin ? JPATH_SITE : JPATH_ADMINISTRATOR;
     $alt_file_root .= '/components/' . $option;
     $template_root = $isAdmin ? JPATH_ADMINISTRATOR : JPATH_SITE;
     $template_root .= '/templates/' . $template . '/html/' . $option;
     // Set up the paths to look into
     $paths = array($template_root . '/' . $view, $template_root . '/' . FOFInflector::singularize($view), $template_root . '/' . FOFInflector::pluralize($view), $file_root . '/views/' . $view . '/tmpl', $file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $alt_file_root . '/views/' . $view . '/tmpl', $alt_file_root . '/views/' . FOFInflector::singularize($view) . '/tmpl', $alt_file_root . '/views/' . FOFInflector::pluralize($view) . '/tmpl', $file_root . '/models/forms', $alt_file_root . '/models/forms');
     // Set up the suffixes to look into
     $jversion = new JVersion();
     $versionParts = explode('.', $jversion->RELEASE);
     $majorVersion = array_shift($versionParts);
     $suffixes = array('.j' . str_replace('.', '', $jversion->getHelpVersion()) . '.xml', '.j' . $majorVersion . '.xml', '.xml');
     unset($jversion, $versionParts, $majorVersion);
     // Look for all suffixes in all paths
     JLoader::import('joomla.filesystem.file');
     $result = false;
     foreach ($paths as $path) {
         foreach ($suffixes as $suffix) {
             $filename = $path . '/' . $source . $suffix;
             if (JFile::exists($filename)) {
                 $result = $filename;
                 break;
             }
         }
         if ($result) {
             break;
         }
     }
     return $result;
 }
Example #15
0
 /**
  * Loads a template given any path. The path is in the format:
  * [admin|site]:com_foobar/viewname/templatename
  * e.g. admin:com_foobar/myview/default
  *
  * This function searches for Joomla! version override templates. For example,
  * if you have run this under Joomla! 3.0 and you try to load
  * admin:com_foobar/myview/default it will automatically search for the
  * template files default.j30.php, default.j3.php and default.php, in this
  * order.
  *
  * @param string $path
  * @param array $forceParams A hash array of variables to be extracted in the local scope of the template file
  */
 public function loadAnyTemplate($path = '', $forceParams = array())
 {
     // Automatically check for a Joomla! version specific override
     $throwErrorIfNotFound = true;
     $jversion = new JVersion();
     $versionParts = explode('.', $jversion->RELEASE);
     $majorVersion = array_shift($versionParts);
     $suffixes = array('.j' . str_replace('.', '', $jversion->getHelpVersion()), '.j' . $majorVersion);
     unset($jversion, $versionParts, $majorVersion);
     foreach ($suffixes as $suffix) {
         if (substr($path, -strlen($suffix)) == $suffix) {
             $throwErrorIfNotFound = false;
             break;
         }
     }
     if ($throwErrorIfNotFound) {
         foreach ($suffixes as $suffix) {
             $result = $this->loadAnyTemplate($path . $suffix, $forceParams);
             if ($result !== false) {
                 return $result;
             }
         }
     }
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     if (!$isCli) {
         $template = JFactory::getApplication()->getTemplate();
     } else {
         $template = 'cli';
     }
     $layoutTemplate = $this->getLayoutTemplate();
     // Parse the path
     $templateParts = $this->_parseTemplatePath($path);
     // Get the default paths
     $paths = array();
     $paths[] = ($templateParts['admin'] ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/templates/' . $template . '/html/' . $templateParts['component'] . '/' . $templateParts['view'];
     $paths[] = ($templateParts['admin'] ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/components/' . $templateParts['component'] . '/views/' . $templateParts['view'] . '/tmpl';
     if (isset($this->_path) || property_exists($this, '_path')) {
         $paths = array_merge($paths, $this->_path['template']);
     } elseif (isset($this->path) || property_exists($this, 'path')) {
         $paths = array_merge($paths, $this->path['template']);
     }
     // Look for a template override
     if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) {
         $apath = array_shift($paths);
         array_unshift($paths, str_replace($template, $layoutTemplate, $apath));
     }
     $filetofind = $templateParts['template'] . '.php';
     JLoader::import('joomla.filesystem.path');
     $this->_tempFilePath = JPath::find($paths, $filetofind);
     if ($this->_tempFilePath) {
         // Unset from local scope
         unset($template);
         unset($layoutTemplate);
         unset($paths);
         unset($path);
         unset($filetofind);
         // Never allow a 'this' property
         if (isset($this->this)) {
             unset($this->this);
         }
         // Force parameters into scope
         if (!empty($forceParams)) {
             extract($forceParams);
         }
         // Start capturing output into a buffer
         ob_start();
         // Include the requested template filename in the local scope
         // (this will execute the view logic).
         include $this->_tempFilePath;
         // Done with the requested template; get the buffer and
         // clear it.
         $this->_output = ob_get_contents();
         ob_end_clean();
         return $this->_output;
     } else {
         if ($throwErrorIfNotFound) {
             return new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $path), 500);
         }
         return false;
     }
 }