Ejemplo n.º 1
0
	static public function getConfigOptions($name) {
		$config = KunenaFactory::getConfig ();
		$options = KunenaIntegration::detectIntegration($name);
		$integration = 'integration_' . $name;
		if (isset($options['none'])) {
			 $none = $options['none'];
			 unset ($options['none']);
		}

		$opt[] = JHTML::_('select.option', 'auto',JText::_('COM_KUNENA_INTEGRATION_AUTO'));
		foreach ($options as $component=>$status) {
			if ($component == 'joomla15' || $component == 'joomla16') {
				if (!$status) continue;
				$component = 'joomla';
			}

			$opt[] = JHTML::_('select.option', $component, JText::_('COM_KUNENA_INTEGRATION_'.strtoupper($component)), 'value', 'text', !$status);
		}
		if (isset($none)) {
			$opt[] = JHTML::_('select.option', 'none', JText::_('COM_KUNENA_INTEGRATION_NONE'), 'value', 'text', !$none);
		}
		return JHTML::_('select.genericlist', $opt, 'cfg_'.$integration, 'class="inputbox" size="1"', 'value', 'text', $config->$integration);
	}
Ejemplo n.º 2
0
 private function getBirthdayUser()
 {
     $from = $this->timeo->format('z', true) + 1;
     $to = $this->datemaxo->format('z', true) + 1;
     if ($this->integration == 'auto') {
         $this->integration = KunenaIntegration::detectIntegration('profile', true);
     }
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select('b.username');
     $query->select('b.name');
     $query->select('b.id AS userid');
     $jomsocial = '';
     if ($this->integration === 'jomsocial') {
         $birthdate = 'value';
         $fromtable = '#__community_fields_values';
         $jomsocial = ' AND a.field_id = 3 ';
         $userid = 'user_id';
     } elseif ($this->integration === 'communitybuilder') {
         //get the list of user birthdays
         $cbfield = $this->params->get('swkbcbfield', 'cb_birthday');
         $birthdate = $db->getEscaped($cbfield);
         $fromtable = '#__comprofiler';
         $userid = 'id';
     } else {
         $birthdate = 'birthdate';
         $fromtable = '#__kunena_users';
         $userid = 'userid';
     }
     $query->select('YEAR(a.' . $birthdate . ') AS year');
     $query->select('MONTH(a.' . $birthdate . ') AS month');
     $query->select('DAYOFMONTH(a.' . $birthdate . ') AS day');
     $query->select('DATEDIFF(DATE(a.' . $birthdate . ') +
                     INTERVAL(YEAR(CURDATE()) - YEAR(a.' . $birthdate . ') + (RIGHT(CURDATE(),5)>RIGHT(DATE(a.' . $birthdate . '),5)))
                     YEAR, CURDATE()) AS till');
     if ($this->params->get('displayage')) {
         $query->select('(YEAR(CURDATE()) - YEAR(a.' . $birthdate . ') + (DAYOFYEAR(CURDATE())>DAYOFYEAR(a.' . $birthdate . '))) AS age');
     }
     $query->from($fromtable . ' AS a');
     $query->innerJoin('#__users AS b ON a.' . $userid . ' = b.id' . $jomsocial);
     $query->where('(DAYOFYEAR(a.' . $birthdate . ')>=' . $db->getEscaped($from));
     if ($from > $to || $this->btimeline >= 365) {
         $query->where('DAYOFYEAR(a.' . $birthdate . ')<=366) OR (DAYOFYEAR(a.' . $birthdate . ')>=0');
         $query->where('DAYOFYEAR(a.' . $birthdate . ')<=' . $db->getEscaped($to) . ')');
     } else {
         $query->where('DAYOFYEAR(a.' . $birthdate . ')<=' . $db->getEscaped($to) . ')');
     }
     $query->order('till');
     if ($this->username == 0) {
         $order = 'name';
     } else {
         $order = 'username';
     }
     $query->order($db->getEscaped($order));
     $db->setQuery($query, 0, $this->params->get('limit'));
     $res = $db->loadAssocList();
     //die();
     if ($db->getErrorMsg()) {
         KunenaError::checkDatabaseError();
         if ($this->integration === 'communitybuilder') {
             $this->app->enqueueMessage(JText::_('SW_KBIRTHDAY_NOCBFIELD_IF'), 'error');
         }
     }
     if (!empty($res)) {
         //setting up the right birthdate
         $todayyear = $this->timeo->format('Y', true);
         foreach ($res as $k => $v) {
             if ($v['year'] == 1 || empty($v['year'])) {
                 unset($res[$k]);
             } else {
                 $res[$k]['birthdate'] = new JDate(mktime(0, 0, 0, $v['month'], $v['day'], $v['year']), $this->soffset);
                 $res[$k]['leapcorrection'] = $res[$k]['birthdate']->format('z', true) + 1;
                 $useryear = $res[$k]['birthdate']->format('Y', true);
                 //we have NOT a leap year?
                 if ($todayyear % 400 != 0 || !($todayyear % 4 == 0 && $todayyear % 100 != 0)) {
                     //was the birthdate in a leap year?
                     if ($useryear % 400 == 0 || $useryear % 4 == 0 && $useryear % 100 != 0) {
                         //if we haven't leap year and birthdate was in leapyear we have to cut yday after february
                         if ($res[$k]['birthdate']->format('m', true) > 2) {
                             $res[$k]['leapcorrection'] -= 1;
                             if ($this->timeo->format('z', true) + 1 > $res[$k]['leapcorrection']) {
                                 unset($res[$k]);
                             }
                         }
                         //was birthday on 29 february? then show it on 1 march
                         if ($v['month'] == 2 && $v['day'] == 29) {
                             $res[$k]['birthdate'] = $res[$k]['birthdate']->add(new DateInterval('P1D'));
                         }
                     }
                 } else {
                     //We have a leap year
                     //Is the birthday not in a leap year?
                     if ($useryear % 400 != 0 || !($useryear % 4 == 0 && $useryear % 100 != 0)) {
                         //if we have leap year and birthday was not, need to increment birthdays after february
                         if ($res[$k]['birthdate']->format('m', true) > 2) {
                             $res[$k]['leapcorrection'] += 1;
                         }
                     }
                 }
             }
         }
     }
     return $res;
 }
Ejemplo n.º 3
0
	function GetMyProfileURL($userid = 0, $task = '', $xhtml = true, $extra = '') {
		if (!$task) {
			// Workaround for menu redirect: be more verbose
			kimport('kunena.integration');
			$profileIntegration = KunenaIntegration::detectIntegration('profile', true);
			if ($profileIntegration != 'kunena') $task='summary';
		}
		$my = JFactory::getUser();
		if ($userid && $userid!=$my->id) $userid = "&userid=$userid";
		else $userid = '';
		if ($task) $task = "&do=$task";
		return KunenaRoute::_ ( "index.php?option=com_kunena&view=profile{$userid}{$task}{$extra}", $xhtml );
	}
Ejemplo n.º 4
0
 function GetMyProfileURL($userid = 0, $task = '', $xhtml = true, $extra = '')
 {
     if (!$task) {
         // Workaround for menu redirect: be more verbose
         kimport('integration.integration');
         $profileIntegration = KunenaIntegration::detectIntegration('profile', true);
         if ($profileIntegration != 'kunena') {
             $task = 'summary';
         }
     }
     $my = JFactory::getUser();
     if ($userid && $userid != $my->id) {
         $userid = "&userid={$userid}";
     } else {
         $userid = '';
     }
     if ($task) {
         $task = "&do={$task}";
     }
     return KunenaRoute::_(KUNENA_LIVEURLREL . "&func=profile{$userid}{$task}{$extra}", $xhtml);
 }