Example #1
0
 public function getRememberMe()
 {
     $db = JFactory::getDbo();
     $db->setQuery("SELECT params from #__modules WHERE module = 'mod_cblogin' ORDER BY ordering", 0, 1);
     $raw_params = $db->loadResult();
     $params = new cbParamsBase($raw_params);
     return $params->get('remember_enabled', 1);
 }
Example #2
0
	public function getRememberMe() {
		$db = JFactory::getDbo();
		// TODO: test if works (see #1079)
		$db->setQuery( "SELECT params FROM #__extensions WHERE element='mod_cblogin' AND type='module'", 0, 1 );
		$raw_params = $db->loadResult();
		$params = new cbParamsBase( $raw_params );
		return $params->get( 'remember_enabled', 1);
	}
Example #3
0
	function _form_mos_menu__menutypes() {
		global $_CB_database;

		$query		=	"SELECT params"
					.	"\n FROM #__modules"
					.	"\n WHERE module = 'mod_mainmenu'"
					//.	"\n ORDER BY title"
					;
		$_CB_database->setQuery( $query	);
		$modMenus	=	$_CB_database->loadObjectList();

		$query		=	"SELECT menutype"
					.	"\n FROM #__menu"
					.	"\n GROUP BY menutype"
					//.	"\n ORDER BY menutype"
					;
		$_CB_database->setQuery( $query	);
		$menuMenus	=	$_CB_database->loadResultArray();

		$menuTypes	=	array();

		foreach ( $modMenus as $modMenu ) {
			$modParams 		=	new cbParamsBase( $modMenu->params );
			$menuType 		=	$modParams->get( 'menutype' );
			if ( ! $menuType ) {
				$menuType	=	'mainmenu';
			}
			if ( ! in_array( $menuType, $menuTypes ) ) {
				$menuTypes[] =	$menuType;
			}
		}

		foreach ( $menuMenus as $menuType ) {
			if ( ! in_array( $menuType, $menuTypes ) ) {
				$menuTypes[] =	$menuType;
			}
		}

		asort( $menuTypes );
		return $menuTypes;
	}
Example #4
0
	/**
	 * Creates the column references for the userlist query
	 * @static
	 *
	 * @param  array         $columns
	 * @param  array         $allFields
	 * @param  array         $tables
	 * @param  array         $searchableFields
	 * @param  cbParamsBase  $params
	 * @return string
	 */
	function getFieldsSQL( &$columns, &$allFields, &$tables, &$searchableFields, &$params ){
		$colRefs										=	array();
	
		$newtableindex									=	0;
	
		$list_search									=	(int) $params->get( 'list_search', 1 );
	
		foreach ( $columns as $i => $column ) {
			foreach ( $column->fields as $k => $fieldid ) {
				if ( isset( $allFields[$fieldid] ) ) {
					// now done in field fetching:
					//	if ( ! is_object( $allFields[$fieldid]->params ) ) {
					//		$allFields[$fieldid]->params	=	new cbParamsBase( $allFields[$fieldid]->params );
					//	}
					$field								=	$allFields[$fieldid];
					if ( ! array_key_exists( $field->table, $tables ) ) {
						$newtableindex++;
						$tables[$field->table]			=  't'.$newtableindex;
					}
	/*
					if ( $field->name == 'avatar' ) {
						$colRefs['avatarapproved']		=	'ue.`avatarapproved`';
						$colRefs['name']				=	'u.`name`';
						$colRefs['username']			=	'******';
					}
					if ( $field->type == 'formatname' ) {
						$colRefs['name']				=	'u.`name`';
						$colRefs['username']			=	'******';
					}
	*/
					if ( ( $tables[$field->table][0] != 'u' ) && ( $field->name != 'NA' ) ) {		// CB 1.1 table compatibility : TBD: remove after CB 1.2
						foreach ( $field->getTableColumns() as $col ) {
							$colRefs[$col]				=	$tables[$field->table] . '.' . $field->_db->NameQuote( $col );
						}
					}
					if ( $field->searchable && ( $list_search == 1 ) ) {
						$searchableFields[]				=&	$allFields[$fieldid];
					}
					$allFields[$fieldid]->_listed		=	true;
				} else {
					// field unpublished or deleted but still in list: remove field from columns, so that we don't handle it:
					unset( $columns[$i]->fields[$k] );
				}
			}
		}
	
		if ( $list_search == 2 ) {
			foreach ( $allFields as $fieldid => $field ) {
				if ( $field->searchable ) {
					$searchableFields[]					=&	$allFields[$fieldid];
				}
			}
		}
		return implode( ', ', $colRefs );
	}
/**
 * Checks if a page is executed https, and if not, if it should be according to login module HTTPS posts specifications
 * 
 * @param  boolean  $return  [default: false] : True: returns if https switchover is needed for the POST form (if not already on HTTPS and login module asks for it). False: errors 403 if not in https and it's configured in login module.
 * @return boolean           True: switchover needed (returned only if $return = true)
 */
function checkCBPostIsHTTPS($return = false)
{
    global $_CB_framework, $_CB_database, $_SERVER;
    $isHttps = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off';
    if (!$isHttps && file_exists($_CB_framework->getCfg('absolute_path') . '/modules/' . (checkJversion() > 0 ? 'mod_cblogin/' : null) . 'mod_cblogin.php')) {
        $query = 'SELECT ' . $_CB_database->NameQuote('params') . "\n FROM " . $_CB_database->NameQuote('#__modules') . "\n WHERE " . $_CB_database->NameQuote('module') . " = " . $_CB_database->Quote('mod_cblogin') . "\n ORDER BY " . $_CB_database->NameQuote('ordering');
        $_CB_database->setQuery($query, 0, 1);
        $module = $_CB_database->loadResult();
        if ($module) {
            $params = new cbParamsBase($module);
            $https_post = $params->get('https_post', 0) != 0;
        } else {
            $https_post = false;
        }
    } else {
        $https_post = false;
    }
    if ($return) {
        return $https_post;
    } else {
        if ($https_post && !$isHttps) {
            header('HTTP/1.0 403 Forbidden');
            exit(_UE_NOT_AUTHORIZED);
        }
    }
}
	/**
	 * saves users notifications
	 *
	 * @param int $catid
	 * @param int $grpid
	 * @param moscomprofilerUser $user
	 * @param object $plugin
	 * @param boolean $silent
	 * @return boolean
	 */
	static public function saveNotifications( $catid, $grpid, $user, $plugin, $silent = true ) {
		$category						=	cbgjData::getCategories( null, array( 'id', '=', (int) $catid ), null, null, false );
		$group							=	cbgjData::getGroups( null, array( 'id', '=', (int) $grpid ), null, null, false );

		if ( ( ! $category->get( 'id' ) ) && $group->get( 'id' ) ) {
			$category					=	$group->getCategory();
		}

		$authorized						=	cbgjClass::getAuthorization( $category, $group, $user );

		if ( cbgjClass::hasAccess( 'usr_notifications', $authorized ) ) {
			$categoryApprove			=	$plugin->params->get( 'category_approve', 0 );
			$groupApprove				=	$plugin->params->get( 'group_approve', 0 );

			if ( cbgjClass::hasAccess( 'gen_usr_notifications', $authorized ) ) {
				$generalNotifications	=	cbgjData::getNotifications( null, array( array( 'type', '=', 'general' ), array( 'user_id', '=', (int) $user->id ) ), null, null, false );

				$generalNotifications->set( 'user_id', (int) $user->id );
				$generalNotifications->set( 'type', 'general' );
				$generalNotifications->set( 'item', 0 );

				if ( $generalNotifications->getError() || ( ! $generalNotifications->store() ) ) {
					if ( ! $silent ) {
						cbgjClass::getPluginURL( array( 'notifications', 'show', (int) $category->get( 'id' ), (int) $group->get( 'id' ) ), CBTxt::P( 'General notifications failed to save! Error: [error]', array( '[error]' => $generalNotifications->getError() ) ), false, true, null, false, false, true );
					}

					return false;
				}

				$generalParams			=	$generalNotifications->getParams();
				$generalCleanParams		=	new cbParamsBase( null );

				$generalCleanParams->set( 'general_categorynew', ( (int) ( cbgjClass::hasAccess( 'usr_mod', $authorized ) ? cbgjClass::getCleanParam( true, 'general_categorynew', $generalParams->get( 'general_categorynew', $plugin->params->get( 'notifications_general_categorynew', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$generalCleanParams->set( 'general_categoryapprove', ( (int) ( cbgjClass::hasAccess( 'usr_mod', $authorized ) && $categoryApprove ? cbgjClass::getCleanParam( true, 'general_categoryapprove', $generalParams->get( 'general_categoryapprove', $plugin->params->get( 'notifications_general_categoryapprove', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$generalCleanParams->set( 'general_categoryupdate', ( (int) ( cbgjClass::hasAccess( 'usr_mod', $authorized ) ? cbgjClass::getCleanParam( true, 'general_categoryupdate', $generalParams->get( 'general_categoryupdate', $plugin->params->get( 'notifications_general_categoryupdate', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$generalCleanParams->set( 'general_categorydelete', ( (int) ( cbgjClass::hasAccess( 'usr_mod', $authorized ) ? cbgjClass::getCleanParam( true, 'general_categorydelete', $generalParams->get( 'general_categorydelete', $plugin->params->get( 'notifications_general_categorydelete', 0 ) ) ) : 0 ) ? 1 : 0 ) );

				if ( $generalNotifications->getError() || ( ! $generalNotifications->storeParams( $generalCleanParams ) ) ) {
					if ( ! $silent ) {
						cbgjClass::getPluginURL( array( 'notifications', 'show', (int) $category->get( 'id' ), (int) $group->get( 'id' ) ), CBTxt::P( 'General notifications failed to save! Error: [error]', array( '[error]' => $generalNotifications->getError() ) ), false, true, null, false, false, true );
					}

					return false;
				}
			}

			if ( cbgjClass::hasAccess( 'cat_usr_notifications', $authorized ) ) {
				$categoryNotifications	=	cbgjData::getNotifications( null, array( array( 'type', '=', 'category' ), array( 'item', '=', (int) $catid ), array( 'user_id', '=', (int) $user->id ) ), null, null, false );

				$categoryNotifications->set( 'user_id', (int) $user->id );
				$categoryNotifications->set( 'type', 'category' );
				$categoryNotifications->set( 'item', (int) $category->get( 'id' ) );

				if ( $categoryNotifications->getError() || ( ! $categoryNotifications->store() ) ) {
					if ( ! $silent ) {
						cbgjClass::getPluginURL( array( 'notifications', 'show', (int) $category->get( 'id' ), (int) $group->get( 'id' ) ), CBTxt::P( '[category] notifications failed to save! Error: [error]', array( '[category]' => cbgjClass::getOverride( 'category' ), '[error]' => $categoryNotifications->getError() ) ), false, true, null, false, false, true );
					}

					return false;
				}

				$categoryParams			=	$categoryNotifications->getParams();
				$categoryCleanParams	=	new cbParamsBase( null );

				$categoryCleanParams->set( 'category_nestednew', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl1', 'cat_nested' ), $authorized, true ) ? cbgjClass::getCleanParam( true, 'category_nestednew', $categoryParams->get( 'category_nestednew', $plugin->params->get( 'notifications_category_nestednew', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$categoryCleanParams->set( 'category_nestedapprove', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl1', 'cat_nested' ), $authorized, true ) && $categoryApprove ? cbgjClass::getCleanParam( true, 'category_nestedapprove', $categoryParams->get( 'category_nestedapprove', $plugin->params->get( 'notifications_category_nestedapprove', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$categoryCleanParams->set( 'category_nestedupdate', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl1', 'cat_nested' ), $authorized, true ) ? cbgjClass::getCleanParam( true, 'category_nestedupdate', $categoryParams->get( 'category_nestedupdate', $plugin->params->get( 'notifications_category_nestedupdate', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$categoryCleanParams->set( 'category_nesteddelete', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl1', 'cat_nested' ), $authorized, true ) ? cbgjClass::getCleanParam( true, 'category_nesteddelete', $categoryParams->get( 'category_nesteddelete', $plugin->params->get( 'notifications_category_nesteddelete', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$categoryCleanParams->set( 'category_groupnew', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl1', 'grp_create' ), $authorized, true ) ? cbgjClass::getCleanParam( true, 'category_groupnew', $categoryParams->get( 'category_groupnew', $plugin->params->get( 'notifications_category_groupnew', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$categoryCleanParams->set( 'category_groupapprove', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl1', 'grp_create' ), $authorized, true ) && $groupApprove ? cbgjClass::getCleanParam( true, 'category_groupapprove', $categoryParams->get( 'category_groupapprove', $plugin->params->get( 'notifications_category_groupapprove', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$categoryCleanParams->set( 'category_groupupdate', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl1', 'grp_create' ), $authorized, true ) ? cbgjClass::getCleanParam( true, 'category_groupupdate', $categoryParams->get( 'category_groupupdate', $plugin->params->get( 'notifications_category_groupupdate', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$categoryCleanParams->set( 'category_groupdelete', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl1', 'grp_create' ), $authorized, true ) ? cbgjClass::getCleanParam( true, 'category_groupdelete', $categoryParams->get( 'category_groupdelete', $plugin->params->get( 'notifications_category_groupdelete', 0 ) ) ) : 0 ) ? 1 : 0 ) );

				if ( $categoryNotifications->getError() || ( ! $categoryNotifications->storeParams( $categoryCleanParams ) ) ) {
					if ( ! $silent ) {
						cbgjClass::getPluginURL( array( 'notifications', 'show', (int) $category->get( 'id' ), (int) $group->get( 'id' ) ), CBTxt::P( '[category] notifications failed to save! Error: [error]', array( '[category]' => cbgjClass::getOverride( 'category' ), '[error]' => $categoryNotifications->getError() ) ), false, true, null, false, false, true );
					}

					return false;
				}
			}

			if ( cbgjClass::hasAccess( 'grp_usr_notifications', $authorized ) ) {
				$groupNotifications		=	cbgjData::getNotifications( null, array( array( 'type', '=', 'group' ), array( 'item', '=', (int) $grpid ), array( 'user_id', '=', (int) $user->id ) ), null, null, false );

				$groupNotifications->set( 'user_id', (int) $user->id );
				$groupNotifications->set( 'type', 'group' );
				$groupNotifications->set( 'item', (int) $group->get( 'id' ) );

				if ( $groupNotifications->getError() || ( ! $groupNotifications->store() ) ) {
					if ( ! $silent ) {
						cbgjClass::getPluginURL( array( 'notifications', 'show', (int) $category->get( 'id' ), (int) $group->get( 'id' ) ), CBTxt::P( '[group] notifications failed to save! Error: [error]', array( '[group]' => cbgjClass::getOverride( 'category' ), '[error]' => $groupNotifications->getError() ) ), false, true, null, false, false, true );
					}

					return false;
				}

				$groupParams			=	$groupNotifications->getParams();
				$groupCleanParams		=	new cbParamsBase( null );

				$groupCleanParams->set( 'group_nestednew', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl2', 'grp_nested' ), $authorized, true ) ? cbgjClass::getCleanParam( true, 'group_nestednew', $groupParams->get( 'group_nestednew', $plugin->params->get( 'notifications_group_nestednew', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$groupCleanParams->set( 'group_nestedapprove', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl2', 'grp_nested' ), $authorized, true ) && $groupApprove ? cbgjClass::getCleanParam( true, 'group_nestedapprove', $groupParams->get( 'group_nestedapprove', $plugin->params->get( 'notifications_group_nestedapprove', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$groupCleanParams->set( 'group_nestedupdate', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl2', 'grp_nested' ), $authorized, true ) ? cbgjClass::getCleanParam( true, 'group_nestedupdate', $groupParams->get( 'group_nestedupdate', $plugin->params->get( 'notifications_group_nestedupdate', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$groupCleanParams->set( 'group_nesteddelete', ( (int) ( cbgjClass::hasAccess( array( 'mod_lvl2', 'grp_nested' ), $authorized, true ) ? cbgjClass::getCleanParam( true, 'group_nesteddelete', $groupParams->get( 'group_nesteddelete', $plugin->params->get( 'notifications_group_nesteddelete', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$groupCleanParams->set( 'group_userjoin', ( (int) ( cbgjClass::hasAccess( 'mod_lvl4', $authorized ) ? cbgjClass::getCleanParam( true, 'group_userjoin', $groupParams->get( 'group_userjoin', $plugin->params->get( 'notifications_group_userjoin', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$groupCleanParams->set( 'group_userleave', ( (int) ( cbgjClass::hasAccess( 'mod_lvl4', $authorized ) ? cbgjClass::getCleanParam( true, 'group_userleave', $groupParams->get( 'group_userleave', $plugin->params->get( 'notifications_group_userleave', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$groupCleanParams->set( 'group_userinvite', ( (int) ( cbgjClass::hasAccess( 'mod_lvl2', $authorized ) ? cbgjClass::getCleanParam( true, 'group_userinvite', $groupParams->get( 'group_userinvite', $plugin->params->get( 'notifications_group_userinvite', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$groupCleanParams->set( 'group_userapprove', ( (int) ( cbgjClass::hasAccess( 'mod_lvl4', $authorized ) ? cbgjClass::getCleanParam( true, 'group_userapprove', $groupParams->get( 'group_userapprove', $plugin->params->get( 'notifications_group_userapprove', 0 ) ) ) : 0 ) ? 1 : 0 ) );
				$groupCleanParams->set( 'group_inviteaccept', ( (int) ( cbgjClass::hasAccess( 'grp_invite', $authorized ) ? cbgjClass::getCleanParam( true, 'group_inviteaccept', $groupParams->get( 'group_inviteaccept', $plugin->params->get( 'notifications_group_inviteaccept', 0 ) ) ) : 0 ) ? 1 : 0 ) );

				if ( $groupNotifications->getError() || ( ! $groupNotifications->storeParams( $groupCleanParams ) ) ) {
					if ( ! $silent ) {
						cbgjClass::getPluginURL( array( 'notifications', 'show', (int) $category->get( 'id' ), (int) $group->get( 'id' ) ), CBTxt::P( '[group] notifications failed to save! Error: [error]', array( '[group]' => cbgjClass::getOverride( 'category' ), '[error]' => $groupNotifications->getError() ) ), false, true, null, false, false, true );
						return false;
					}

					return false;
				}
			}

			if ( ! $silent ) {
				cbgjClass::getPluginURL( array( 'notifications', 'show', (int) $category->get( 'id' ), (int) $group->get( 'id' ) ), CBTxt::T( 'Notifications saved successfully!' ), false, true, null, false, false, true );
			}

			return true;
		} else {
			if ( ! $silent ) {
				cbgjClass::getPluginURL( array( 'overview' ), CBTxt::T( 'Not authorized.' ), false, true, 'error' );
			}

			return false;
		}
	}