function plug_cbgroupjiveabout_install()
{
	// Grab GJ params to migrate the legacy params:
	$plugin				=	new PluginTable();

	$plugin->load( array( 'element' => 'cbgroupjive' ) );

	$pluginParams		=	new Registry( $plugin->get( 'params' ) );

	if ( ( ! $pluginParams->has( 'about_content' ) ) || ( $pluginParams->get( 'about_content' ) == null ) ) {
		return;
	}

	// Migrate about integration parameters:
	$about				=	new PluginTable();

	$about->load( array( 'element' => 'cbgroupjiveabout' ) );

	$aboutParams		=	new Registry( $about->get( 'params' ) );

	if ( $aboutParams->get( 'migrated' ) ) {
		return;
	}

	$aboutParams->set( 'groups_about_content_plugins', $pluginParams->get( 'about_content' ) );
	$aboutParams->set( 'migrated', true );

	$about->set( 'params', $aboutParams->asJson() );

	$about->store();
}
function plug_cbgroupjiveforums_install()
{
	// Grab GJ params to migrate the legacy params:
	$plugin				=	new PluginTable();

	$plugin->load( array( 'element' => 'cbgroupjive' ) );

	$pluginParams		=	new Registry( $plugin->get( 'params' ) );

	if ( ( ! $pluginParams->has( 'forum_id' ) ) || ( $pluginParams->get( 'forum_id' ) == null ) ) {
		return;
	}

	// Migrate forums integration parameters:
	$forums				=	new PluginTable();

	$forums->load( array( 'element' => 'cbgroupjiveforums' ) );

	$forumsParams		=	new Registry( $forums->get( 'params' ) );

	if ( $forumsParams->get( 'migrated' ) ) {
		return;
	}

	$forumsParams->set( 'groups_forums_category', $pluginParams->get( 'forum_id' ) );
	$forumsParams->set( 'groups_forums_paging', $pluginParams->get( 'forum_paging' ) );
	$forumsParams->set( 'groups_forums_limit', $pluginParams->get( 'forum_limit' ) );
	$forumsParams->set( 'groups_forums_search', $pluginParams->get( 'forum_search' ) );
	$forumsParams->set( 'migrated', true );

	$forums->set( 'params', $forumsParams->asJson() );

	$forums->store();
}
function plug_cbgroupjivevideo_install()
{
	// Grab GJ params to migrate the legacy params:
	$plugin				=	new PluginTable();

	$plugin->load( array( 'element' => 'cbgroupjive' ) );

	$pluginParams		=	new Registry( $plugin->get( 'params' ) );

	if ( ( ! $pluginParams->has( 'video_captcha' ) ) || ( $pluginParams->get( 'video_captcha' ) == null ) ) {
		return;
	}

	// Migrate video integration parameters:
	$video				=	new PluginTable();

	$video->load( array( 'element' => 'cbgroupjivevideo' ) );

	$videoParams		=	new Registry( $video->get( 'params' ) );

	if ( $videoParams->get( 'migrated' ) ) {
		return;
	}

	$videoParams->set( 'groups_video_captcha', $pluginParams->get( 'video_captcha' ) );
	$videoParams->set( 'groups_video_paging', $pluginParams->get( 'video_paging' ) );
	$videoParams->set( 'groups_video_limit', $pluginParams->get( 'video_limit' ) );
	$videoParams->set( 'groups_video_search', $pluginParams->get( 'video_search' ) );
	$videoParams->set( 'migrated', true );

	$video->set( 'params', $videoParams->asJson() );

	$video->store();
}
Ejemplo n.º 4
0
 /**
  * Constructor (must stay old-named for compatibility with CBSubs GPL 3.0.0)
  *
  * @param  Registry          $pluginParams  The parameters of the plugin
  * @param  SimpleXMLElement  $types         The types definitions in XML
  * @param  SimpleXMLElement  $actions       The actions definitions in XML
  * @param  SimpleXMLElement  $views         The views definitions in XML
  * @param  PluginTable       $pluginObject  The plugin object
  * @param  int               $tabId         The tab id (if there is one)
  */
 public function cbEditRowView($pluginParams, $types, $actions, $views, $pluginObject, $tabId = null)
 {
     global $_CB_database;
     $input = Application::Input();
     /** @noinspection PhpDeprecationInspection */
     if ($pluginParams instanceof cbParamsBase) {
         // Backwards-compatibility:
         /** @noinspection PhpDeprecationInspection */
         $pluginParams = new Registry($pluginParams->toParamsArray());
     }
     $this->registryEditView = new RegistryEditView($input, $_CB_database, $pluginParams, $types, $actions, $views, $pluginObject, $tabId);
     foreach (array_keys(get_object_vars($this->registryEditView)) as $k) {
         $this->{$k} =& $this->registryEditView->{$k};
     }
 }
	/**
	 * @param  TabTable   $tab       Current tab
	 * @param  UserTable  $user      Current user
	 * @param  int        $ui        1 front, 2 admin UI
	 * @param  array      $postdata  Raw unfiltred POST data
	 * @return string                HTML
	 */
	public function getCBpluginComponent( $tab, $user, $ui, $postdata )
	{
		$format				=	$this->input( 'format', null, GetterInterface::STRING );

		if ( $format != 'raw' ) {
			outputCbJs();
			outputCbTemplate();
		}

		$action				=	$this->input( 'action', null, GetterInterface::STRING );
		$function			=	$this->input( 'func', null, GetterInterface::STRING );
		$id					=	(int) $this->input( 'id', null, GetterInterface::INT );
		$user				=	CBuser::getMyUserDataInstance();

		if ( $format != 'raw' ) {
			ob_start();
		}

		switch ( $action ) {
			case 'wall':
				switch ( $function ) {
					case 'publish':
						$this->stateWall( 1, $id, $user );
						break;
					case 'unpublish':
						$this->stateWall( 0, $id, $user );
						break;
					case 'delete':
						$this->deleteWall( $id, $user );
						break;
					case 'new':
						$this->showWallEdit( null, $user );
						break;
					case 'edit':
						$this->showWallEdit( $id, $user );
						break;
					case 'save':
						cbSpoofCheck( 'plugin' );
						$this->saveWallEdit( $id, $user );
						break;
				}
				break;
		}

		if ( $format != 'raw' ) {
			$html			=	ob_get_contents();
			ob_end_clean();

			$class			=	$this->_gjParams->get( 'general_class', null );

			$return			=	'<div class="cbGroupJive' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">'
							.		'<div class="cbGroupJiveInner">'
							.			$html
							.		'</div>'
							.	'</div>';

			echo $return;
		}
	}
function plug_cb_profilebook_uninstall()
{
	global $_CB_database;

	$html_return			=	'';
	
	// if needed get cb profilebook plugin parameters
	$plugparms_query		=	"SELECT params"
							.	"\n FROM #__comprofiler_plugin"
							.	"\n WHERE element='cb.profilebook'";
	$_CB_database->setQuery( $plugparms_query );
	$cbpbplugparms			=	$_CB_database->loadResult();

	$params					=	new Registry( $cbpbplugparms );

	if ( $params->get( 'pbUnistallMode' ) ) {			// if full unistall mode parameter selected then purge everything
		$drop_table_query	=	'DROP TABLE `#__comprofiler_plug_profilebook`';
		$_CB_database->setQuery( $drop_table_query );
		$ret				=	$_CB_database->query();
		if( ! $ret ) {
			$html_return	.=	'<div style="font-size:14px;color:red;margin-bottom:10px;">Failed to drop table #__comprofiler_plug_profilebook</div>';
		} else {
			$html_return	.=	'<div style="font-size:14px;color:green;margin-bottom:10px;">Table #__comprofiler_plug_profilebook deleted (all items lost)</div>';
		}
		$drop_fields_query	=	"ALTER TABLE `#__comprofiler` DROP COLUMN `cb_pb_enable`,"
							.	"\n DROP COLUMN `cb_pb_autopublish`,"
							.	"\n DROP COLUMN `cb_pb_notifyme`";	
		$_CB_database->setQuery( $drop_fields_query );
		$ret				=	$_CB_database->query();
		if( ! $ret ) {
			$html_return	.=	'<div style="font-size:14px;color:red;margin-bottom:10px;">Failed to delete Plugin fields from #__comprofiler table</div>';
		} else {
			$html_return	.=	'<div style="font-size:14px;color:green;margin-bottom:10px;">Plugin fields deleted from #__comprofiler table (all personalization lost)</div>';
		}
	} else {
		// just unistall plugin code - keep all data
		$html_return		.=	'<div style="font-size:14px;color:green;margin-bottom:10px;">The profilebook plugin has been deleted but data remains so upgrade is possible</div>';
	}
	# Show installation result to user
	echo 'Plugin successfully uninstalled. See bellow for extra status messages';
	return $html_return;
}
 /**
  * Gets a param value
  *
  * @param  string|string[]        $key      Name of index or array of names of indexes, each with name or input-name-encoded array selection, e.g. a.b.c
  * @param  mixed|GetterInterface  $default  [optional] Default value, or, if instanceof GetterInterface, parent GetterInterface for the default value
  * @param  string|array           $type     [optional] default: null: raw. Or const int GetterInterface::COMMAND|GetterInterface::INT|... or array( const ) or array( $key => const )
  * @return string|array
  *
  * @throws \InvalidArgumentException        If namespace doesn't exist
  */
 public function get($key, $default = null, $type = null)
 {
     if (substr($key, 0, 11) == 'permission:') {
         $parts = explode(':', substr($key, 11));
         if (count($parts) < 2) {
             return cbpaidApp::authoriseAction($parts[0]) ? 1 : 0;
         } else {
             return cbpaidApp::authoriseAction($parts[1], $parts[0]) ? 1 : 0;
         }
     }
     return parent::get($key, $default);
 }
function plug_cbgroupjivewall_install()
{
	// Grab GJ params to migrate the legacy params:
	$plugin				=	new PluginTable();

	$plugin->load( array( 'element' => 'cbgroupjive' ) );

	$pluginParams		=	new Registry( $plugin->get( 'params' ) );

	if ( ( ! $pluginParams->has( 'wall_inputlimit' ) ) || ( $pluginParams->get( 'wall_inputlimit' ) == null ) ) {
		return;
	}

	// Migrate wall integration parameters:
	$wall				=	new PluginTable();

	$wall->load( array( 'element' => 'cbgroupjivewall' ) );

	$wallParams			=	new Registry( $wall->get( 'params' ) );

	if ( $wallParams->get( 'migrated' ) ) {
		return;
	}

	$wallParams->set( 'groups_wall_character_limit', $pluginParams->get( 'wall_inputlimit' ) );
	$wallParams->set( 'groups_wall_replies', $pluginParams->get( 'wall_reply' ) );
	$wallParams->set( 'groups_wall_replies_paging', $pluginParams->get( 'wall_replypaging' ) );
	$wallParams->set( 'groups_wall_replies_limit', $pluginParams->get( 'wall_replylimit' ) );
	$wallParams->set( 'groups_wall_paging', $pluginParams->get( 'wall_paging' ) );
	$wallParams->set( 'groups_wall_limit', $pluginParams->get( 'wall_limit' ) );
	$wallParams->set( 'migrated', true );

	$wall->set( 'params', $wallParams->asJson() );

	$wall->store();
}
function plug_cbgroupjivefile_install()
{
	// Grab GJ params to migrate the legacy params:
	$plugin				=	new PluginTable();

	$plugin->load( array( 'element' => 'cbgroupjive' ) );

	$pluginParams		=	new Registry( $plugin->get( 'params' ) );

	if ( ( ! $pluginParams->has( 'file_captcha' ) ) || ( $pluginParams->get( 'file_captcha' ) == null ) ) {
		return;
	}

	// Migrate file integration parameters:
	$file				=	new PluginTable();

	$file->load( array( 'element' => 'cbgroupjivefile' ) );

	$fileParams			=	new Registry( $file->get( 'params' ) );

	if ( $fileParams->get( 'migrated' ) ) {
		return;
	}

	$fileParams->set( 'groups_file_captcha', $pluginParams->get( 'file_captcha' ) );
	$fileParams->set( 'groups_file_max_size', $pluginParams->get( 'file_maxsize' ) );
	$fileParams->set( 'groups_file_extensions', $pluginParams->get( 'file_types' ) );
	$fileParams->set( 'groups_file_paging', $pluginParams->get( 'file_paging' ) );
	$fileParams->set( 'groups_file_limit', $pluginParams->get( 'file_limit' ) );
	$fileParams->set( 'groups_file_search', $pluginParams->get( 'file_search' ) );
	$fileParams->set( 'migrated', true );

	$file->set( 'params', $fileParams->asJson() );

	$file->store();
}
Ejemplo n.º 10
0
	/**
	 * Parses a string for PHP functions
	 *
	 * @param string $input
	 * @param array  $vars
	 * @return string
	 */
	static public function formatCondition( $input, $vars = array() )
	{
																// \[cb:parse(?: +function="([^"/\[\] ]+)")( +(?: ?[a-zA-Z-_]+="(?:[^"]|\\")+")+)?(?:(?:\s*/])|(?:]((?:[^\[]|\[(?!/?cb:parse[^\]]*])|(?R))+)?\[/cb:parse]))
		$regex												=	'%\[cb:parse(?: +function="([^"/\[\] ]+)")( +(?: ?[a-zA-Z-_]+="(?:[^"]|\\\\")+")+)?(?:(?:\s*/])|(?:]((?:[^\[]|\[(?!/?cb:parse[^\]]*])|(?R))+)?\[/cb:parse]))%i';

		if ( preg_match_all( $regex, $input, $results, PREG_SET_ORDER ) ) {
			foreach( $results as $matches ) {
				$function									=	( isset( $matches[1] ) ? $matches[1] : null );

				if ( $function ) {
					$value									=	( isset( $matches[3] ) ? self::formatCondition( $matches[3], $vars ) : null );
					$options								=	new Registry();

					if ( isset( $matches[2] ) ) {
						if ( preg_match_all( '/(?:([a-zA-Z-_]+)="((?:[^"]|\\\\\\\\")+)")+/i', $matches[2], $optionResults, PREG_SET_ORDER ) ) {
							foreach( $optionResults as $option ) {
								$k							=	( isset( $option[1] ) ? $option[1] : null );
								$v							=	( isset( $option[2] ) ? $option[2] : null );

								if ( $k ) {
									$options->set( $k, $v );
								}
							}
						}
					}

					$method									=	$options->get( 'method' );

					$options->unsetEntry( 'method' );

					switch ( $function ) {
						case 'clean':
							switch( $method ) {
								case 'cmd':
									$input					=	str_replace( $matches[0], Get::clean( $value, GetterInterface::COMMAND ), $input );
									break;
								case 'numeric':
									$input					=	str_replace( $matches[0], Get::clean( $value, GetterInterface::NUMERIC ), $input );
									break;
								case 'unit':
									$input					=	str_replace( $matches[0], Get::clean( $value, GetterInterface::UINT ), $input );
									break;
								case 'int':
								case 'integer':
									$input					=	str_replace( $matches[0], Get::clean( $value, GetterInterface::INT ), $input );
									break;
								case 'bool':
								case 'boolean':
									$input					=	str_replace( $matches[0], Get::clean( $value, GetterInterface::BOOLEAN ), $input );
									break;
								case 'str':
								case 'string':
									$input					=	str_replace( $matches[0], Get::clean( $value, GetterInterface::STRING ), $input );
									break;
								case 'html':
									$input					=	str_replace( $matches[0], Get::clean( $value, GetterInterface::HTML ), $input );
									break;
								case 'float':
									$input					=	str_replace( $matches[0], Get::clean( $value, GetterInterface::FLOAT ), $input );
									break;
								case 'base64':
									$input					=	str_replace( $matches[0], Get::clean( $value, GetterInterface::BASE64 ), $input );
									break;
								case 'tags':
									$input					=	str_replace( $matches[0], strip_tags( $value ), $input );
									break;
							}
							break;
						case 'convert':
							switch( $method ) {
								case 'uppercase':
									$input					=	str_replace( $matches[0], strtoupper( $value ), $input );
									break;
								case 'uppercasewords':
									$input					=	str_replace( $matches[0], ucwords( $value ), $input );
									break;
								case 'uppercasefirst':
									$input					=	str_replace( $matches[0], ucfirst( $value ), $input );
									break;
								case 'lowercase':
									$input					=	str_replace( $matches[0], strtolower( $value ), $input );
									break;
								case 'lowercasefirst':
									$input					=	str_replace( $matches[0], lcfirst( $value ), $input );
									break;
							}
							break;
						case 'math':
							$input							=	str_replace( $matches[0], self::formatMath( $value ), $input );
							break;
						case 'time':
							$input							=	str_replace( $matches[0], ( $options->has( 'time' ) ? strtotime( $options->get( 'time', null, GetterInterface::STRING ), ( is_numeric( $value ) ? (int) $value : strtotime( $value ) ) ) : strtotime( $value ) ), $input );
							break;
						case 'date':
							$offset							=	$options->get( 'offset' );
							$input							=	str_replace( $matches[0], cbFormatDate( ( is_numeric( $value ) ? (int) $value : strtotime( $value ) ), ( $offset ? true : false ), true, $options->get( 'date-format' ), $options->get( 'time-format' ), ( $offset != 'true' ? $offset : null ) ), $input );
							break;
						case 'length':
							$input							=	str_replace( $matches[0], strlen( $value ), $input );
							break;
						case 'replace':
							$input							=	str_replace( $matches[0], ( $options->has( 'count' ) ? str_replace( $options->get( 'search' ), $options->get( 'replace' ), $value, $options->get( 'count', 0, GetterInterface::INT ) ) : str_replace( $options->get( 'search' ), $options->get( 'replace' ), $value ) ), $input );
							break;
						case 'position':
							switch( $options->get( 'occurrence' ) ) {
								case 'last':
									$input					=	str_replace( $matches[0], strrpos( $value, $options->get( 'search' ) ), $input );
									break;
								case 'first':
								default:
									$input					=	str_replace( $matches[0], strpos( $value, $options->get( 'search' ) ), $input );
									break;
							}
							break;
						case 'occurrence':
							$input							=	str_replace( $matches[0], strstr( $value, $options->get( 'search' ) ), $input );
							break;
						case 'repeat':
							$input							=	str_replace( $matches[0], str_repeat( $value, $options->get( 'count', 0, GetterInterface::INT ) ), $input );
							break;
						case 'extract':
							$input							=	str_replace( $matches[0], ( $options->has( 'length' ) ? substr( $value, $options->get( 'start', 0, GetterInterface::INT ), $options->get( 'length', 0, GetterInterface::INT ) ) : substr( $value, $options->get( 'start', 0, GetterInterface::INT ) ) ), $input );
							break;
						case 'trim':
							switch( $options->get( 'direction' ) ) {
								case 'left':
									$input					=	str_replace( $matches[0], ( $options->has( 'characters' ) ? ltrim( $value, $options->get( 'characters', null, GetterInterface::STRING ) ) : ltrim( $value ) ), $input );
									break;
								case 'right':
									$input					=	str_replace( $matches[0], ( $options->has( 'characters' ) ? rtrim( $value, $options->get( 'characters', null, GetterInterface::STRING ) ) : rtrim( $value ) ), $input );
									break;
								default:
									$input					=	str_replace( $matches[0], ( $options->has( 'characters' ) ? trim( $value, $options->get( 'characters', null, GetterInterface::STRING ) ) : trim( $value ) ), $input );
									break;
							}
							break;
						case 'encode':
							switch( $method ) {
								case 'cslashes':
									$input					=	str_replace( $matches[0], addcslashes( $value, $options->get( 'characters', null, GetterInterface::STRING ) ), $input );
									break;
								case 'slashes':
									$input					=	str_replace( $matches[0], addslashes( $value ), $input );
									break;
								case 'entity':
									$input					=	str_replace( $matches[0], htmlentities( $value ), $input );
									break;
								case 'html':
									$input					=	str_replace( $matches[0], htmlspecialchars( $value ), $input );
									break;
								case 'url':
									$input					=	str_replace( $matches[0], urlencode( $value ), $input );
									break;
								case 'base64':
									$input					=	str_replace( $matches[0], base64_encode( $value ), $input );
									break;
								case 'md5':
									$input					=	str_replace( $matches[0], md5( $value ), $input );
									break;
								case 'sha1':
									$input					=	str_replace( $matches[0], sha1( $value ), $input );
									break;
								case 'password':
									$user					=	new UserTable();

									$input					=	str_replace( $matches[0], $user->hashAndSaltPassword( $value ), $input );
									break;
							}
							break;
						case 'decode':
							switch( $method ) {
								case 'cslashes':
									$input					=	str_replace( $matches[0], stripcslashes( $value ), $input );
									break;
								case 'slashes':
									$input					=	str_replace( $matches[0], stripslashes( $value ), $input );
									break;
								case 'entity':
									$input					=	str_replace( $matches[0], html_entity_decode( $value ), $input );
									break;
								case 'html':
									$input					=	str_replace( $matches[0], htmlspecialchars_decode( $value ), $input );
									break;
								case 'url':
									$input					=	str_replace( $matches[0], urldecode( $value ), $input );
									break;
								case 'base64':
									$input					=	str_replace( $matches[0], base64_encode( $value ), $input );
									break;
							}
							break;
						default:
							if ( ! $function ) {
								continue;
							}

							$class							=	$options->get( 'class', null, GetterInterface::STRING );
							$subFunction					=	null;
							$static							=	false;
							$result							=	null;

							if ( strpos( $function, '::' ) !== false ) {
								list( $class, $function )	=	explode( '::', $function, 2 );

								$static						=	true;
							} elseif ( strpos( $class, '::' ) !== false ) {
								$subFunction				=	$function;

								list( $class, $function )	=	explode( '::', $class, 2 );

								$static						=	true;
							}

							if ( $class ) {
								$object						=	null;

								$options->unsetEntry( 'class' );

								if ( isset( $vars[$class] ) && is_object( $vars[$class] ) ) {
									$object					=	$vars[$class];
									$class					=	get_class( $object );
								}

								if ( $static ) {
									if ( $subFunction ) {
										if ( is_callable( array( $class, $function ) ) ) {
											$object			=	call_user_func_array( array( $class, $function ), array() );

											if ( method_exists( $object, $subFunction ) ) {
												$result		=	call_user_func_array( array( $object, $subFunction ), $options->asArray() );
											}
										}
									} else {
										if ( is_callable( array( $class, $function ) ) ) {
											$result			=	call_user_func_array( array( $class, $function ), $options->asArray() );
										}
									}
								} else {
									if ( $object || class_exists( $class ) ) {
										if ( ! $object ) {
											$object			=	new $class();

											if ( $value && method_exists( $object, 'load' ) ) {
												$object->load( $value );
											}
										}

										if ( method_exists( $object, $function ) ) {
											$result			=	call_user_func_array( array( $object, $function ), $options->asArray() );
										}
									}
								}
							} else {
								if ( function_exists( $function ) ) {
									$result					=	call_user_func_array( $function, $options->asArray() );
								}
							}

							if ( $method && is_object( $result ) && method_exists( $result, $method ) ) {
								$result						=	call_user_func_array( array( $result, $method ), $options->asArray() );
							}

							if ( ( ! is_array( $result ) ) && ( ! is_object( $result ) ) ) {
								$input						=	str_replace( $matches[0], $result, $input );
							}
							break;
					}

					// If no replacement is done above then the string still exists; lets just replace the substitution with the found value:
					$input									=	str_replace( $matches[0], $value, $input );
				}
			}

			$input											=	self::formatCondition( $input, $vars );
		}

		return $input;
	}
Ejemplo n.º 11
0
function plug_cbgroupjive_install()
{
	global $_CB_database, $_PLUGINS;

	// Uninstall the old integrations to avoid conflicts:
	$integrations									=	array(	'cbgroupjiveabout', 'cbgroupjiveevents', 'cbgroupjivefile',
																'cbgroupjiveforums', 'cbgroupjivephoto', 'cbgroupjivevideo',
																'cbgroupjivewall', 'cbgroupjiveauto'
															);

	foreach ( $integrations as $integration ) {
		$plugin										=	new PluginTable();

		$plugin->load( array( 'element' => $integration ) );

		if ( $plugin->get( 'id' ) && ( ! is_dir( $_PLUGINS->getPluginPath( $plugin ) . '/xml' ) ) ) {
			$plugin->delete();
		}
	}

	// Migrate categories:
	$table											=	'#__groupjive_categories';
	$fields											=	$_CB_database->getTableFields( $table );
	$migrate										=	false;

	if ( isset( $fields[$table]['parent'] ) ) {
		$migrate									=	true;

		$query										=	'SELECT *'
													.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_categories' );
		$_CB_database->setQuery( $query );
		$categories									=	$_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( $_CB_database, '#__groupjive_categories', 'id' ) );

		/** @var $categories Table[] */
		foreach ( $categories as $category ) {
			$category->set( 'access', ( $category->get( 'access' ) == -2 ? 1 : ( $category->get( 'access' ) == -1 ? 2 : Application::CmsPermissions()->convertOldGroupToViewAccessLevel( $category->get( 'access' ), 'CB GroupJive: Category Access - ' . (int) $category->get( 'id' ) ) ) ) );
			$category->set( 'create_access', ( ! $category->get( 'create' ) ? -1 : ( $category->get( 'create_access' ) == -1 ? 2 : Application::CmsPermissions()->convertOldGroupToViewAccessLevel( $category->get( 'create_access' ), 'CB GroupJive: Category Create Access - ' . (int) $category->get( 'id' ) ) ) ) );

			$categoryParams							=	new Registry( $category->get( 'params' ) );

			// CB GroupJive Forums:
			$categoryParams->set( 'forums', $categoryParams->get( 'forum_show' ) );

			$category->set( 'params', $categoryParams->asJson() );

			$category->store();
		}

		// Remove the old columns:
		$_CB_database->dropColumn( $table, 'parent' );
		$_CB_database->dropColumn( $table, 'create' );
		$_CB_database->dropColumn( $table, 'nested' );
		$_CB_database->dropColumn( $table, 'nested_access' );
	}

	// Migrate groups:
	$table											=	'#__groupjive_groups';
	$fields											=	$_CB_database->getTableFields( $table );

	if ( isset( $fields[$table]['parent'] ) ) {
		$migrate									=	true;

		$query										=	'SELECT *'
													.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_groups' );
		$_CB_database->setQuery( $query );
		$groups										=	$_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( $_CB_database, '#__groupjive_groups', 'id' ) );

		/** @var $groups Table[] */
		foreach ( $groups as $group ) {
			$groupParams							=	new Registry( $group->get( 'params' ) );

			// Core:
			$groupParams->set( 'invites', ( $group->get( 'invite' ) > 0 ? 0 : 1 ) );

			// CB GroupJive Events:
			$groupParams->set( 'events', ( $groupParams->get( 'events_approve' ) ? 2 : $groupParams->get( 'events_show' ) ) );

			// CB GroupJive File:
			$groupParams->set( 'file', ( $groupParams->get( 'file_approve' ) ? 2 : $groupParams->get( 'file_show' ) ) );

			// CB GroupJive Forums:
			$groupParams->set( 'forums', $groupParams->get( 'forum_show' ) );

			// CB GroupJive Photo:
			$groupParams->set( 'photo', ( $groupParams->get( 'photo_approve' ) ? 2 : $groupParams->get( 'photo_show' ) ) );

			// CB GroupJive Video:
			$groupParams->set( 'video', ( $groupParams->get( 'video_approve' ) ? 2 : $groupParams->get( 'video_show' ) ) );

			// CB GroupJive Wall:
			$groupParams->set( 'wall', ( $groupParams->get( 'wall_approve' ) ? 2 : $groupParams->get( 'wall_show' ) ) );

			$group->set( 'params', $groupParams->asJson() );

			$group->store();
		}

		// Remove the old columns:
		$_CB_database->dropColumn( $table, 'parent' );
		$_CB_database->dropColumn( $table, 'access' );
		$_CB_database->dropColumn( $table, 'invite' );
		$_CB_database->dropColumn( $table, 'users' );
		$_CB_database->dropColumn( $table, 'nested' );
		$_CB_database->dropColumn( $table, 'nested_access' );
	}

	// Migrate notifications:
	$table											=	'#__groupjive_notifications';
	$fields											=	$_CB_database->getTableFields( $table );

	if ( isset( $fields[$table]['type'] ) ) {
		$migrate									=	true;

		// Delete notification types no longer supported:
		$query										=	'DELETE'
													.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_notifications' )
													.	"\n WHERE " . $_CB_database->NameQuote( 'type' ) . " != " . $_CB_database->Quote( 'group' );
		$_CB_database->setQuery( $query );
		$_CB_database->query();

		// Migration notification parameters:
		$query										=	'SELECT *'
													.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_notifications' );
		$_CB_database->setQuery( $query );
		$notifications								=	$_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( $_CB_database, '#__groupjive_notifications', 'id' ) );

		/** @var $notifications Table[] */
		foreach ( $notifications as $notification ) {
			if ( ( $notification->get( 'type' ) == 'group' ) && $notification->get( 'item' ) ) {
				$notification->set( 'group', (int) $notification->get( 'item' ) );

				$notificationParams					=	new Registry( $notification->get( 'params' ) );

				// Core:
				$notificationParams->set( 'user_join', $notificationParams->get( 'group_userjoin' ) );
				$notificationParams->set( 'user_leave', $notificationParams->get( 'group_userleave' ) );
				$notificationParams->set( 'user_approve', $notificationParams->get( 'group_userapprove' ) );
				$notificationParams->set( 'invite_accept', $notificationParams->get( 'group_inviteaccept' ) );

				// CB GroupJive Events:
				$notificationParams->set( 'event_new', $notificationParams->get( 'group_eventnew' ) );
				$notificationParams->set( 'event_approve', $notificationParams->get( 'group_eventapprove' ) );
				$notificationParams->set( 'event_attend', $notificationParams->get( 'group_eventyes' ) );
				$notificationParams->set( 'event_unattend', $notificationParams->get( 'group_eventno' ) );

				// CB GroupJive File:
				$notificationParams->set( 'file_new', $notificationParams->get( 'group_filenew' ) );
				$notificationParams->set( 'file_approve', $notificationParams->get( 'group_fileapprove' ) );

				// CB GroupJive Photo:
				$notificationParams->set( 'photo_new', $notificationParams->get( 'group_photonew' ) );
				$notificationParams->set( 'photo_approve', $notificationParams->get( 'group_photoapprove' ) );

				// CB GroupJive Video:
				$notificationParams->set( 'video_new', $notificationParams->get( 'group_videonew' ) );
				$notificationParams->set( 'video_approve', $notificationParams->get( 'group_videoapprove' ) );

				// CB GroupJive Wall:
				$notificationParams->set( 'wall_new', $notificationParams->get( 'group_wallnew' ) );
				$notificationParams->set( 'wall_approve', $notificationParams->get( 'group_wallapprove' ) );
				$notificationParams->set( 'wall_reply', $notificationParams->get( 'group_wallreply' ) );

				$notification->set( 'params', $notificationParams->asJson() );

				$notification->store();
			}
		}

		// Remove the old columns:
		$_CB_database->dropColumn( $table, 'type' );
		$_CB_database->dropColumn( $table, 'item' );
	}

	if ( $migrate ) {
		// Migrate global parameters:
		$plugin										=	new PluginTable();

		$plugin->load( array( 'element' => 'cbgroupjive' ) );

		$pluginParams								=	new Registry( $plugin->get( 'params' ) );

		// Logos:
		$pluginParams->set( 'logo_max_size', $pluginParams->get( 'logo_size' ) );
		$pluginParams->set( 'logo_image_width', $pluginParams->get( 'logo_width' ) );
		$pluginParams->set( 'logo_image_height', $pluginParams->get( 'logo_height' ) );
		$pluginParams->set( 'logo_thumbnail_width', $pluginParams->get( 'logo_thumbwidth' ) );
		$pluginParams->set( 'logo_thumbnail_height', $pluginParams->get( 'logo_thumbheight' ) );

		// Notifications:
		$pluginParams->set( 'notifications', $pluginParams->get( 'general_notifications' ) );
		$pluginParams->set( 'notifications_notifyby', ( $pluginParams->get( 'general_notifyby' ) < 4 ? 2 : 1 ) );
		$pluginParams->set( 'notifications_default_user_join', $pluginParams->get( 'notifications_group_userjoin' ) );
		$pluginParams->set( 'notifications_default_user_leave', $pluginParams->get( 'notifications_group_userleave' ) );
		$pluginParams->set( 'notifications_default_user_approve', $pluginParams->get( 'notifications_group_userapprove' ) );
		$pluginParams->set( 'notifications_default_invite_accept', $pluginParams->get( 'notifications_group_inviteaccept' ) );

		// Categories:
		$pluginParams->set( 'categories_paging', $pluginParams->get( 'overview_paging' ) );
		$pluginParams->set( 'categories_limit', $pluginParams->get( 'overview_limit' ) );
		$pluginParams->set( 'categories_search', $pluginParams->get( 'overview_search' ) );

		switch( (int) $pluginParams->get( 'overview_orderby' ) ) {
			case 7:
				$orderBy							=	5;
				break;
			case 8:
				$orderBy							=	6;
				break;
			case 5:
				$orderBy							=	3;
				break;
			case 6:
				$orderBy							=	4;
				break;
			case 1:
			case 2:
				$orderBy							=	(int) $pluginParams->get( 'overview_orderby' );
				break;
			case 3:
			case 4:
			case 9:
			case 10:
			default:
				$orderBy							=	1;
				break;
		}

		$pluginParams->set( 'categories_orderby', $orderBy );
		$pluginParams->set( 'categories_groups_paging', $pluginParams->get( 'category_groups_paging' ) );
		$pluginParams->set( 'categories_groups_limit', $pluginParams->get( 'category_groups_limit' ) );
		$pluginParams->set( 'categories_groups_search', $pluginParams->get( 'category_groups_search' ) );
		$pluginParams->set( 'categories_groups_orderby', ( $pluginParams->get( 'category_groups_orderby' ) > 8 ? 4 : $pluginParams->get( 'category_groups_orderby' ) ) );

		// Groups:
		$pluginParams->set( 'groups_create_access', ( ! $pluginParams->get( 'group_create' ) ? -1 : ( $pluginParams->get( 'group_create_access' ) == -1 ? 2 : Application::CmsPermissions()->convertOldGroupToViewAccessLevel( $pluginParams->get( 'group_create_access' ), 'CB GroupJive: Groups Create Access' ) ) ) );
		$pluginParams->set( 'groups_create_limit', $pluginParams->get( 'group_limit' ) );
		$pluginParams->set( 'groups_create_approval', $pluginParams->get( 'group_approve' ) );
		$pluginParams->set( 'groups_create_captcha', $pluginParams->get( 'group_captcha' ) );
		$pluginParams->set( 'groups_message', $pluginParams->get( 'group_message' ) );
		$pluginParams->set( 'groups_message_captcha', $pluginParams->get( 'group_message_captcha' ) );
		$pluginParams->set( 'groups_users_paging', $pluginParams->get( 'group_users_paging' ) );
		$pluginParams->set( 'groups_users_limit', $pluginParams->get( 'group_users_limit' ) );
		$pluginParams->set( 'groups_users_search', $pluginParams->get( 'group_users_search' ) );
		$pluginParams->set( 'groups_invites_display', $pluginParams->get( 'group_invites_display' ) );
		$pluginParams->set( 'groups_invites_by', $pluginParams->get( 'group_invites_by' ) );
		$pluginParams->set( 'groups_invites_list', $pluginParams->get( 'group_invites_list' ) );
		$pluginParams->set( 'groups_invites_accept', $pluginParams->get( 'group_invites_accept' ) );
		$pluginParams->set( 'groups_invites_captcha', $pluginParams->get( 'group_invites_captcha' ) );
		$pluginParams->set( 'groups_invites_paging', $pluginParams->get( 'group_invites_paging' ) );
		$pluginParams->set( 'groups_invites_limit', $pluginParams->get( 'group_invites_limit' ) );
		$pluginParams->set( 'groups_invites_search', $pluginParams->get( 'group_invites_search' ) );
		$pluginParams->set( 'groups_paging', $pluginParams->get( 'group_all_paging' ) );
		$pluginParams->set( 'groups_limit', $pluginParams->get( 'group_all_limit' ) );
		$pluginParams->set( 'groups_search', $pluginParams->get( 'group_all_search' ) );
		$pluginParams->set( 'groups_orderby', ( $pluginParams->get( 'group_all_orderby' ) > 8 ? 4 : $pluginParams->get( 'group_all_orderby' ) ) );

		$plugin->set( 'params', $pluginParams->asJson() );

		$plugin->store();

		// Migrate the old auto fields to core GJ:
		$query										=	'UPDATE '. $_CB_database->NameQuote( '#__comprofiler_fields' )
													.	"\n SET " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'groupautojoin' )
													.	', ' . $_CB_database->NameQuote( 'pluginid' ) . ' = ' . (int) $plugin->get( 'id' )
													.	"\n WHERE " . $_CB_database->NameQuote( 'type' ) . " = " . $_CB_database->Quote( 'cbgjautojoin' );
		$_CB_database->setQuery( $query );
		$_CB_database->query();

		// Migrate tab parameters:
		$tab										=	new TabTable();

		$tab->load( array( 'pluginclass' => 'cbgjTab' ) );

		$tabParams									=	new Registry( $tab->get( 'params' ) );

		$tabParams->set( 'tab_paging', $pluginParams->get( 'group_tab_paging' ) );
		$tabParams->set( 'tab_limit', $pluginParams->get( 'group_tab_limit' ) );
		$tabParams->set( 'tab_search', $pluginParams->get( 'group_tab_search' ) );
		$tabParams->set( 'tab_orderby', ( $pluginParams->get( 'group_tab_orderby' ) > 8 ? 4 : $pluginParams->get( 'group_tab_orderby' ) ) );

		$tab->set( 'params', $tabParams->asJson() );

		$tab->store();
	}

	// Migrate gj auto to cb auto actions if possible:
	$table											=	'#__groupjive_plugin_auto';

	if ( $_CB_database->getTableStatus( $table ) ) {
		$fields										=	$_CB_database->getTableFields( $table );

		if ( isset( $fields[$table]['trigger'] ) ) {
			$autoActions							=	new PluginTable();

			$autoActions->load( array( 'element' => 'cbautoactions' ) );

			if ( $autoActions->get( 'id' ) ) {
				$table								=	'#__comprofiler_plugin_autoactions';
				$fields								=	$_CB_database->getTableFields( $table );

				if ( ! isset( $fields[$table]['conditions'] ) ) {
					return;
				}

				$query								=	'SELECT *'
													.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_auto' );
				$_CB_database->setQuery( $query );
				$autos								=	$_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( $_CB_database, '#__groupjive_plugin_auto', 'id' ) );

				/** @var $autos Table[] */
				foreach ( $autos as $auto ) {
					$oldParams						=	new Registry( $auto->get( 'params' ) );

					if ( $oldParams->get( 'migrated' ) ) {
						continue;
					}

					$newParams						=	new Registry();
					$newConditions					=	null;

					if ( $auto->get( 'field' ) ) {
						$fields						=	new Registry( $auto->get( 'field' ) );
						$operators					=	new Registry( $auto->get( 'operator' ) );
						$values						=	new Registry( $auto->get( 'value' ) );

						$conditionals				=	count( $fields );

						if ( $conditionals ) {
							$conditions				=	array();

							for ( $i = 0, $n = $conditionals; $i < $n; $i++ ) {
								$field				=	$fields->get( "field$i" );
								$operator			=	$operators->get( "operator$i" );
								$value				=	$values->get( "value$i" );

								if ( $operator ) {
									$conditions[]	=	array( 'field' => $field, 'operator' => $operator, 'value' => $value, 'translate' => 0 );
								}
							}

							if ( $conditions ) {
								$newConditionals	=	new Registry( $conditions );
								$newConditions		=	$newConditionals->asJson();
							}
						}
					}

					$mode							=	$oldParams->get( 'auto' );

					$join							=	array(	'mode'					=>	$mode,
																'groups'				=>	$oldParams->get( 'groups' ),
																'status'				=>	$oldParams->get( 'status' ),
																'name'					=>	( $mode == 2 ? $oldParams->get( 'grp_name' ) : $oldParams->get( 'cat_name' ) ),
																'category'				=>	$oldParams->get( 'category' ),
																'category_name'			=>	$oldParams->get( 'cat_name' ),
																'category_parent'		=>	$oldParams->get( 'cat_parent' ),
																'category_types'		=>	$oldParams->get( 'types' ),
																'category_description'	=>	$oldParams->get( 'cat_description' ),
																'category_unique'		=>	$oldParams->get( 'cat_unique' ),
																'group_parent'			=>	$oldParams->get( 'grp_parent' ),
																'type'					=>	$oldParams->get( 'type' ),
																'parent'				=>	$oldParams->get( 'cat_parent' ),
																'types'					=>	$oldParams->get( 'types' ),
																'description'			=>	( $mode == 2 ? $oldParams->get( 'grp_description' ) : $oldParams->get( 'cat_description' ) ),
																'owner'					=>	( $mode == 2 ? $oldParams->get( 'grp_owner' ) : $oldParams->get( 'cat_owner' ) ),
																'unique'				=>	( $mode == 2 ? $oldParams->get( 'grp_unique' ) : $oldParams->get( 'cat_unique' ) ),
																'autojoin'				=>	$oldParams->get( 'grp_autojoin' ),
																'group_status'			=>	$oldParams->get( 'status' )
															);

					$newParams->set( 'groupjive', array( $join ) );
					$newParams->set( 'exclude', $auto->get( 'exclude' ) );

					$query							=	'INSERT IGNORE INTO '. $_CB_database->NameQuote( '#__comprofiler_plugin_autoactions' )
													.	' ( '
													.		$_CB_database->NameQuote( 'published' )
													.		', ' . $_CB_database->NameQuote( 'title' )
													.		', ' . $_CB_database->NameQuote( 'description' )
													.		', ' . $_CB_database->NameQuote( 'type' )
													.		', ' . $_CB_database->NameQuote( 'trigger' )
													.		', ' . $_CB_database->NameQuote( 'object' )
													.		', ' . $_CB_database->NameQuote( 'variable' )
													.		', ' . $_CB_database->NameQuote( 'access' )
													.		', ' . $_CB_database->NameQuote( 'conditions' )
													.		', ' . $_CB_database->NameQuote( 'params' )
													.	' ) VALUES ( '
													.		(int) $auto->get( 'published' )
													.		', ' . $_CB_database->Quote( $auto->get( 'title' ) )
													.		', ' . $_CB_database->Quote( $auto->get( 'description' ) )
													.		', ' . $_CB_database->Quote( 'groupjive' )
													.		', ' . $_CB_database->Quote( str_replace( ',', '|*|', $auto->get( 'trigger' ) ) )
													.		', ' . $_CB_database->Quote( $auto->get( 'object' ) )
													.		', ' . $_CB_database->Quote( $auto->get( 'variable' ) )
													.		', ' . $_CB_database->Quote( $auto->get( 'access' ) )
													.		', ' . $_CB_database->Quote( $newConditions )
													.		', ' . $_CB_database->Quote( $newParams->asJson() )
													.	' )';
					$_CB_database->setQuery( $query );
					$_CB_database->query();

					$oldParams->set( 'migrated', true );

					$auto->set( 'params', $oldParams->asJson() );

					$auto->store();
				}
			}
		}
	}
}
Ejemplo n.º 12
0
	/**
	 * Internal method to get all menu types
	 *
	 * @return string[]
	 */
	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 Registry( $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;				//FIXME: this seems quite broken! (but as unused it's ok for now)
	}
Ejemplo n.º 13
0
	/**
	 * @param cbinvitesInviteTable[] $rows
	 * @param cbPageNav              $pageNav
	 * @param bool                   $searching
	 * @param array                  $input
	 * @param UserTable              $viewer
	 * @param UserTable              $user
	 * @param TabTable               $tab
	 * @param cbTabHandler           $plugin
	 * @return string
	 */
	static function showTab( $rows, $pageNav, $searching, $input, $viewer, $user, $tab, $plugin )
	{
		global $_CB_framework, $_CB_database;

		$params						=	new Registry( $tab->params );
		$profileOwner				=	( $viewer->get( 'id' ) == $user->get( 'id' ) );
		$cbModerator				=	Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator();

		$tabPaging					=	$params->get( 'tab_paging', 1 );
		$canSearch					=	( $params->get( 'tab_search', 1 ) && ( $searching || $pageNav->total ) );

		$inviteLimit				=	(int) $plugin->params->get( 'invite_limit', null );
		$canCreate					=	false;
                
                $user_groups_can_create = array(12,16); //proizvoditeli, komercheskie organizacii
                $gids = $user->get('gids');

		if ( $profileOwner ) {
			if ( $cbModerator ) {
				$canCreate			=	true;
			} elseif ( $user->get( 'id' )   ) {
				if ( $inviteLimit ) {
					$query			=	'SELECT COUNT(*)'
									.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_invites' )
									.	"\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $user->get( 'id' )
									.	"\n AND ( " . $_CB_database->NameQuote( 'user' ) . " IS NULL OR " . $_CB_database->NameQuote( 'user' ) . " = " . $_CB_database->Quote( '' ) . " )";
					$_CB_database->setQuery( $query );
					$inviteCount	=	(int) $_CB_database->loadResult();

					if ( $inviteCount < $inviteLimit ) {
						$canCreate	=	true;
					}
				} else {
					$canCreate		=	true;
				}
			}
		}
                $groupcancreate = false;
                if($gids){
                    foreach($gids as $gid){
                        if(in_array($gid, $user_groups_can_create)){
                            $groupcancreate = true;
                        }
                    }
                    
                }
                
                if(!$groupcancreate){
                    $canCreate = false;
                }

		$return						=	'<div class="medizdTab">'
									.		'<form action="' . $_CB_framework->userProfileUrl( $user->get( 'id' ), true, $tab->tabid ) . '" method="post" name="medizdForm" id="inviteForm" class="medizdForm">';

		if ( $canCreate || $canSearch ) {
			$return					.=			'<div class="medizdHeader row" style="margin-bottom: 10px;">';

			if ( $canCreate ) {
				$return				.=				'<div class="' . ( ! $canSearch ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">'
									.					'<button type="button" onclick="location.href=\'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'medizd', 'func' => 'new' ) ) . '\';" class="invitesButton invitesButtonNew btn btn-success"><span class="fa fa-plus-circle"></span> ' . CBTxt::T( 'MEDPR_NEW_PRODUCT' ) . '</button>'
									.				'</div>';
			}

			if ( $canSearch ) {
				$return				.=				'<div class="' . ( ! $canCreate ? 'col-sm-offset-8 ' : null ) . 'col-sm-4 text-right">'
									.					'<div class="input-group">'
									.						'<span class="input-group-addon"><span class="fa fa-search"></span></span>'
									.						$input['search']
									.					'</div>'
									.				'</div>';
			}

			$return					.=			'</div>';
		}

		$menuAccess					=	( $cbModerator || $profileOwner );

		

		$return						.=			'<table class="invitesContainer table table-hover table-responsive">'
									.				'<thead>'
									.					'<tr>'
									.						'<th class="text-left">' . CBTxt::T( 'MEDPR_CODE' ) . '</th>'
									.						'<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T( 'Name' ) . '</th>'
									.						'<th style="width: 5%;" class="text-center hidden-xs">' . CBTxt::T( 'Date' ) . '</th>'
                                                                        .                                               '<th style="width: 1%;" class="text-left hidden-xs"></th>'
									.					'</tr>'
									.				'</thead>'
									.				'<tbody>';

		if ( $rows ) foreach ( $rows as $row ) {
			

			$return					.=					'<tr>'
									.						'<td class="text-left"><a href="'.JRoute::_(JUri::base().'index.php?option=com_medicineproducts&view=item&id='.$row->id).'">' . $row->code . '</td>'
									.						'<td style="width: 50%;" class="text-left hidden-xs">'
									.							$row->name
									.						'</td>'
									.						'<td style="width: 25%;" class="text-center hidden-xs">'
                                                                        .                                               $row->created;

			

			$return					.=						'</td>';

			if ( ( $cbModerator || $profileOwner )    ) {
				$menuItems			=	'<ul class="invitesMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">';

                                    $link = $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'medizd', 'func' => 'edit', 'id' => (int) $row->get( 'id' )));
				
					$menuItems		.=		'<li class="invitesMenuItem"><a href="' . $link . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>'
									.		'<li class="invitesMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'MEDPR_CONFIRM_DEL' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'medizd', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>';
				

				$menuItems			.=	'</ul>';

				$menuAttr			=	cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' );

				$return				.=						'<td style="width: 1%;" class="text-right">'
									.							'<div class="invitesMenu btn-group">'
									.								'<button type="button"' . $menuAttr . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>'
									.							'</div>'
									.						'</td>';
			} else{
				$return				.=						'<td style="width: 1%;" class="text-right"></td>';
			}

			$return					.=					'</tr>';
		} else {
			$return					.=					'<tr>'
									.						'<td colspan="3" class="text-left">';

			if ( $searching ) {
				$return				.=							CBTxt::T( 'MEDPR_PRODUCT_SEARCH_NULL' );
			} else {
				if ( $viewer->id == $user->id ) {
					$return			.=							CBTxt::T( 'MEDPR_NO_PRODUCT' );
				} else {
					$return			.=							CBTxt::T( 'MEDPR_USER_NO_PRODUCT' );
				}
			}

			$return					.=						'</td>'
									.					'</tr>';
		}

		$return						.=				'</tbody>';

		if ( $tabPaging && ( $pageNav->total > $pageNav->limit ) ) {
			$return					.=				'<tfoot>'
									.					'<tr>'
									.						'<td colspan="3" class="text-center">'
									.							$pageNav->getListLinks()
									.						'</td>'
									.					'</tr>'
									.				'</tfoot>';
		}

		$return						.=			'</table>'
									.			$pageNav->getLimitBox( false )
									.		'</form>'
									.	'</div>';

		return $return;
	}
	/**
	 * display basket and payment buttons or redirect for payment depending if multiple payment choices or intro text present:
	 *
	 * @param  UserTable            $user
	 * @param  cbpaidPaymentBasket  $paymentBasket
	 * @param  string               $introText
	 * @param  boolean              $ajax           TRUE if AJAX refresh inside #cbregPayMethodsChoice, FALSE: wraps in <div id="cbregPayMethodsChoice">
	 * @return string                               HTML  (or DOES REDIRECT if $redirectNow = ! ( ( $nbClasses != 1 ) || $introText ) == TRUE)
	 */
	public function getPaymentBasketPaymentForm( &$user, &$paymentBasket, $introText, $ajax = false ) {
		global $_PLUGINS;

		$result								=	null;

		$params								=	cbpaidApp::settingsParams();
		$invoicingAddressQuery				=	$params->get( 'invoicing_address_query' );
		$basket_requiredterms				=	$params->get( 'basket_requiredterms' );
		$basket_requiredtermserror			=	$params->get( 'basket_requiredtermserror' );
		$payment_method_selection_type		=	$params->get( 'payment_method_selection_type', 'buttons' );
		$allow_select_currency				=	$params->get( 'allow_select_currency', '0' );

		$redirectNow						=	null;
		$payChoicesArray					=	$this->getPaymentMethodsParams( $user, $paymentBasket, $introText, $redirectNow );

		$chosenPaymentMethod				=	$paymentBasket->gateway_account ? $paymentBasket->gateway_account . '-' . $paymentBasket->payment_type : '';		// cbGetParam( $_POST, 'payment_method' );

		$payChoicesHtmlRadiosArray			=	array();
		$chosenPaymentSelector				=	null;
		$payChoicesHtmlBottomArray			=	$this->_renderPayChoicesArray( $payChoicesArray, $paymentBasket, $redirectNow, $chosenPaymentMethod, $payChoicesHtmlRadiosArray, $chosenPaymentSelector );
		if ( $redirectNow == 'redirect' && is_string( $payChoicesHtmlBottomArray ) ) {
			cbRedirect( $payChoicesHtmlBottomArray );
		}

		$subscriptionsGUI					=	new cbpaidControllerUI();
		$subscriptionsGUI->addcbpaidjsplugin();

		if ( ( $payment_method_selection_type == 'radios') && ( $chosenPaymentMethod != '' ) && $chosenPaymentSelector ) {
			// Select button to draw:
			$payChoicePayButton				=	$this->getPayMethodButton( $user, $paymentBasket, $paymentBasket->gateway_account, $paymentBasket->payment_type, $chosenPaymentSelector );
			/** @var $chosenPaymentSelector cbpaidGatewaySelector */
			$this->modifyAspectPayMethodButton( $payChoicePayButton, $chosenPaymentSelector->paymentType );
			$dummy							=	null;
			$payChoicePayButtonHtmlArray	=	$this->_renderPayChoicesArray( array( $payChoicePayButton ), $paymentBasket, 'buttons', $chosenPaymentMethod, $payChoicesHtmlRadiosArray, $dummy );
			$payChoicesHtmlBottomArray		=	array_merge( $payChoicesHtmlBottomArray, $payChoicePayButtonHtmlArray );
		}

		if ( true )  {
			// always add cancel link
			cbpaidApp::import( 'processors.cancelpay.cancelpay' );
			$cancelmethod					=	new cbpaidGatewayAccountcancelpay();
			$payClass						=	$cancelmethod->getPayMean();
			$payChoicesHtmlBottomArray[]	=	$payClass->getPaymentBasketProcess( $user, $paymentBasket, 'buttons' );	// never redirectNow a cancel link :D !
		}

		$basketHtml							=	$paymentBasket->displayBasket();

		if ( $allow_select_currency == 2 ) {
			$currencySelector				=	$this->displayCurrencySelector( $paymentBasket );
		} else {
			$currencySelector				=	null;
		}
		$txtConclusion						=	$params->get('conclusion_text');
		$txtFinal							=	$params->get('final_text');

		$txtTerms						=	null;
		if ( $basket_requiredterms == 1 ) {
			global $_CB_database, $_CB_framework;

			$query							=	'SELECT ' . $_CB_database->NameQuote( 'params' )
											.	"\n FROM " .  $_CB_database->NameQuote( '#__comprofiler_fields' )
											.	"\n WHERE " . $_CB_database->NameQuote( 'name' ) . " = " . $_CB_database->Quote( 'acceptedterms' );
			$_CB_database->setQuery( $query );
			$tcParams						=	new Registry( $_CB_database->loadResult() );

			$termsOutput					=	$tcParams->get( 'terms_output', 'url' );
			$termsDisplay					=	$tcParams->get( 'terms_display', 'modal' );
			$termsURL						=	$tcParams->get( 'terms_url', null );
			$termsText						=	$tcParams->get( 'terms_text', null );
			$termsWidth						=	(int) $tcParams->get( 'terms_width', 400 );
			$termsHeight					=	(int) $tcParams->get( 'terms_height', 200 );

			if ( ! $termsHeight ) {
				$termsHeight				=	200;
			}

			if ( ( ( $termsOutput == 'url' ) && $termsURL ) || ( ( $termsOutput == 'text' ) && $termsText ) ) {
				if ( $termsDisplay == 'iframe' ) {
					if ( $termsOutput == 'url' ) {
						$txtTerms			.=				'<iframe class="cbTermsFrameURL" height="' . $termsHeight . '" width="' . ( $termsWidth ? $termsWidth : '100%' ) . '" src="' . htmlspecialchars( $termsURL ) . '"></iframe>';
					} else {
						$txtTerms			.=				'<div class="cbTermsFrameText" style="height:' . $termsHeight . 'px;width:' . ( $termsWidth ? $termsWidth . 'px' : '100%' ) . ';overflow:auto;">' . CBPTXT::T( $termsText ) . '</div>';
					}
				}

				if ( $termsDisplay != 'iframe' ) {
					$attributes				=	' class="cbTermsLink"';

					if ( ( $termsOutput == 'text' ) && ( $termsDisplay == 'window' ) ) {
						$termsDisplay		=	'modal';
					}

					if ( $termsDisplay == 'modal' ) {
						if ( ! $termsWidth ) {
							$termsWidth		=	400;
						}

						if ( $termsOutput == 'url' ) {
							$tooltip		=	'<iframe class="cbTermsModalURL" height="' . $termsHeight . '" width="' . $termsWidth . '" src="' . htmlspecialchars( $termsURL ) . '"></iframe>';
						} else {
							$tooltip		=	'<div class="cbTermsModalText" style="height:' . $termsHeight . 'px;width:' . $termsWidth . 'px;overflow:auto;">' . CBPTXT::T( $termsText ) . '</div>';
						}

						$url				=	'javascript:void(0);';
						$attributes			.=	' ' . cbTooltip( $_CB_framework->getUi(), $tooltip, CBPTXT::T( 'Terms and Conditions' ), 'auto', null, null, null, 'data-cbtooltip="true" data-modal="true"' );
					} else {
						$url				=	htmlspecialchars( $termsURL );
						$attributes			.=	' target="_blank"';
					}

					$txtTerms				.=				CBPTXT::P( 'I have read and approve the <a href="[url]"[attributes]>Terms and Conditions</a>', array( '[url]' => $url, '[attributes]' => $attributes ) );
				} else {
					$txtTerms				.=				CBPTXT::T( 'I have read and approve the above Terms and Conditions.' );
				}
			}
		} elseif ( $basket_requiredterms == 2 ) {
			$txtTerms					=	$params->get( 'basket_termsandconditions' );
		}

		if ($introText) {
			$result						.=	'<div class="cbregIntro">' . CBPTXT::Th( $introText ) . "</div>\n";
		}
		$result							.=	$basketHtml;

		if ( $allow_select_currency == 2 ) {
			$result						.=	$currencySelector;
		}

		if ( $invoicingAddressQuery > 0 ) {
			$errorMsg					=	$paymentBasket->checkAddressComplete();
			if ( $errorMsg && ( $invoicingAddressQuery == 2 ) ) {
				$result					=	'';
				$introAddrNeeded		=	$params->get('invoicing_address_required_into_text');
				if ($introAddrNeeded) {
					$result				.=	'<div class="cbregIntro">' . CBPTXT::Th( $introAddrNeeded ) . "</div>\n";
				}
				$result					.=	$paymentBasket->renderInvoicingAddressForm( $user );	// $xmlController->handleAction( 'action', 'editinvoiceaddress' );
				return $result;
			} else {
				if ( $errorMsg ) {
					cbpaidApp::getBaseClass()->_setErrorMSG( $errorMsg );
				}
				$result					.=	'<div class="cbregInvoicingAddress">'
					.	$paymentBasket->renderInvoicingAddressFieldset()
					.	'</div>';
			}
			// display current invoicing address with a link to change/edit it with a back link to the payment basket id
			// if the address is not mandatory.
			// If it is mandatory, check that it is complete (and later also screened),
			// if not display instead of this the invoicing address edit page !
		}
		$integrationsResults			=	$_PLUGINS->trigger( 'onCbSubsAfterPaymentBasket', array( $paymentBasket, &$result, &$txtTerms ) );
		foreach ( $integrationsResults as $intRes ) {
			if ( is_string( $intRes ) ) {
				$result					.=	$intRes;
			}
		}
		if ( $txtConclusion ) {
			$result						.=	'<div class="cbregConcl">' . CBPTXT::Th( $txtConclusion ) . "</div>\n";
		}

		if ( count( $payChoicesHtmlRadiosArray ) > 0 ) {

			$radios_intro_html			=	CBPTXT::Th( $params->get( 'radios_intro_html' ) );
			$radios_conclusion_html		=	CBPTXT::Th( $params->get( ( $chosenPaymentMethod != null ) ? 'radios_selected_conclusion_html' : 'radios_unselected_conclusion_html' ) );

			$htmlList					=	'<ul class="cbregPaymentMethodChoiceList">' . "\n";
			foreach ( $payChoicesHtmlRadiosArray as $selHtmlArr ) {
				if ( $selHtmlArr[0] ) {
					$htmlList			.=	'<li class="cbregCCradioLi cbregCCradioSelected">';
				} else {
					$htmlList			.=	'<li class="cbregCCradioLi">';				//LATER:  class="cbpaidCCradio cbpaidRadio_<?php echo htmlspecialchars( $this->payNameForCssClass ); " id="<?php echo htmlspecialchars( $this->butId );
				}
				$htmlList				.=	'<div class="cbregCCradioLiBg"></div>'		// This allows to use the CSS trick for highlighting as explained here: http://www.commentcamarche.net/forum/affich-3898635-transparance-du-fond-uniquement
					.	$selHtmlArr[1]
					.	"</li>\n";
			}
			$htmlList					.=	"</ul>\n";

			$methodsHTML				=	'<div class="cbregPaymentMethodChoice ' . ( ( $chosenPaymentMethod != null ) ? 'cbregPMselected' : 'cbregPMunselected' ) . '">'
				.	( $radios_intro_html ? '<h2 class="contentheading cbregPaymenMethodChoiceIntro">' . $radios_intro_html . '</h2>' : '' )
				.	$htmlList
				.	'<span class="cb_button_wrapper">'
				.	'<button type="submit" id="cbregSelectPayment">' . CBPTXT::Th("Change Payment Method") . '</button>'
				.	'</span>'
				.	( $radios_conclusion_html ? '<div class="cbregPaymenMethodChoiceConclusion">' . $radios_conclusion_html . '</div>' : '' )
				.	"</div>\n"
			;
			$getParams					=	$paymentBasket->getSetBasketPaymentMethodUrl( $user );
			$ajaxGetParams				=	cbUnHtmlspecialchars( $paymentBasket->getSetBasketPaymentMethodUrl( $user, 'raw' ) );
			$formHiddens				=	array(	cbpaidApp::getBaseClass()->_getPagingParamName('act') => 'setbsktpmtmeth',
				'ajaxurl' => bin2hex( $ajaxGetParams ) );
			$result						.=	'<div class="cbregPaymentMethodsSelect">' . $subscriptionsGUI->drawForm( $methodsHTML, null, $formHiddens, $getParams ) . "</div>\n";
			$termsCanBeDisplayed		=	( $payment_method_selection_type != 'radios' ) || ( $chosenPaymentMethod != null );
		} else {
			$termsCanBeDisplayed		=	true;
		}

		if ( $txtTerms ) {
			if ( $termsCanBeDisplayed ) {
				$accepted				=	( cbGetParam( $_POST, 'terms_accepted', 0 ) == 1 );
				$settings				=	'<div class="cbregTermsAccept"><input type="checkbox" class="required" name="terms_accepted" id="terms_accepted" value="1"'
					.	( $accepted ? ' checked="checked" disabled="disabled" ' : '' )
					.	'/> '
					.	'<label for="terms_accepted">'
					.	$txtTerms
					.	'</label></div>'
				;
				if ( ! $accepted ) {
					$settings			.=	'<span class="cb_button_wrapper">'
						.	'<button type="submit" id="cbTermsAccept" title="' . htmlspecialchars( CBPTXT::T( $basket_requiredtermserror ) ) . '">' . CBPTXT::Th("Accept Terms") . '</button>'
						.	'</span>'
					;
				}
				$getParams				=	$accepted ? '#' : $paymentBasket->getShowBasketUrl( false );
				$formHiddens			=	$accepted ? array( 'terms_accepted' => 1 ) : array();
				$result					.=	'<div class="cbregTerms">' . $subscriptionsGUI->drawForm( $settings, null, $formHiddens, $getParams ) . "</div>\n";
			} else {
				$accepted				=	false;
			}
		} else {
			$accepted					=	true;
		}

		$result							.=	'<div class="cbpayChoices cbclearboth"'
			.	( $termsCanBeDisplayed && $txtTerms && ! $accepted ? ' style="display:none;"' : '' )
			.	">\n "
			.	implode ( "\n  ", $payChoicesHtmlBottomArray )
			.	"\n</div>\n";
		if ( $txtFinal ) {
			$result						.=	'<div class="cbregFinalText">' . CBPTXT::Th( $txtFinal ) . "</div>\n";
		}

		$result							=	'<div class="cbpayBasketView">' . $result . '</div>';
		if ( ! $ajax ) {
			$result						=	'<div id="cbpayOrderContainer">'	// Needed for Javascript delegated binding
				.	$result
				.	'</div>';
		}
		return $result;
	}
 /**
  * Evaluates $postdata which is the $_POST array of the form submission of the cbpaidProductView::draw() form,
  * and returns the filtered unescaped options.
  *
  * @param  string           $selectionId     html input tag attribute id=''    field for the input
  * @param  string           $selectionName   html input tag attribute name=''  field for the input
  * @param  string           $selectionValue  html input tag attribute value='' field for the input
  * @param  string           $reason          Payment reason: 'N'=new subscription (default), 'R'=renewal, 'U'=update
  * @return ParamsInterface                   Product's selected options
  */
 public function getOptions($selectionId, $selectionName, $selectionValue, $reason)
 {
     $optionParams = new Registry('');
     $this->_setOptionNames($selectionId, $selectionName, false);
     $selectedvalue = (double) $this->_getReqParam($this->_donselName);
     $donval = abs((double) $this->_getReqParam($this->_donvalName));
     $this->fixedchoices = $this->_model->getParam('fixedchoices', 1);
     $this->defaultchoice = $this->_model->getParam('defaultchoice', '');
     $minimumDonation = (double) $this->_model->getParam('minimumdonation', '');
     $maximumDonation = (double) $this->_model->getParam('maximumdonation', '');
     $this->donateamounts = explode(',', $this->_model->getParam('donateamount', ''));
     $this->_trimArray($this->donateamounts);
     $amount = 0;
     if ($this->fixedchoices > 1 && in_array($selectedvalue, $this->donateamounts)) {
         $amount = $selectedvalue;
     } elseif ($selectedvalue == '' && $this->fixedchoices != 2) {
         if ($donval < $minimumDonation) {
             return CBPTXT::T("Amount too small") . '.';
         } elseif ($maximumDonation != 0 && $donval > $maximumDonation) {
             return CBPTXT::T("Amount too large") . '.';
         }
         $amount = $donval;
     }
     if ($amount == 0) {
         return CBPTXT::T("Amount not allowed") . '.';
     }
     $optionParams->set('amount', $amount);
     return $optionParams;
 }
Ejemplo n.º 16
0
	/**
	 * store default notifications
	 *
	 * @param \CB\Plugin\GroupJive\Table\UserTable $row
	 * @param Registry                             $notifications
	 */
	public function storeNotifications( $row, &$notifications )
	{
		$notifications->set( 'wall_new', $this->params->get( 'notifications_default_wall_new', 0 ) );
		$notifications->set( 'wall_approve', $this->params->get( 'notifications_default_wall_approve', 0 ) );
		$notifications->set( 'wall_reply', $this->params->get( 'notifications_default_wall_reply', 0 ) );
	}
Ejemplo n.º 17
0
function plug_cbgallery_install()
{
	global $_CB_framework, $_CB_database;

	$plugin								=	new PluginTable();

	if ( $plugin->load( array( 'element' => 'cb.profilegallery' ) ) ) {
		$path							=	$_CB_framework->getCfg( 'absolute_path' );
		$indexPath						=	$path . '/components/com_comprofiler/plugin/user/plug_cbgallery/index.html';
		$oldFilesPath					=	$path . '/images/comprofiler/plug_profilegallery';
		$newFilesPath					=	$path . '/images/comprofiler/plug_cbgallery';

		$query							=	'SELECT *'
										.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plug_profilegallery' );
		$_CB_database->setQuery( $query );
		$rows							=	$_CB_database->loadObjectList( null, '\CBLib\Database\Table\Table', array( $_CB_database, '#__comprofiler_plug_profilegallery', 'id' ) );

		/** @var $rows Table[] */
		foreach ( $rows as $row ) {
			$oldFilePath				=	$oldFilesPath . '/' . (int) $row->get( 'userid' );

			if ( in_array( $row->get( 'pgitemtype' ), array( 'jpg', 'jpeg', 'gif', 'png' ) ) ) {
				$type					=	'photos';
			} else {
				$type					=	'files';
			}

			$newFilePath				=	$newFilesPath . '/' . (int) $row->get( 'userid' ) . '/' . $type;

			if ( ( ! file_exists( $oldFilePath . '/' . $row->get( 'pgitemfilename' ) ) ) || ( ( $type == 'photos' ) && ( ! file_exists( $oldFilePath . '/tn' . $row->get( 'pgitemfilename' ) ) ) ) ) {
				continue;
			}

			$cleanFileName				=	str_replace( 'pg_', '', pathinfo( $row->get( 'pgitemfilename' ), PATHINFO_FILENAME ) );
			$newFileName				=	uniqid( $cleanFileName . '_' ) . '.' . strtolower( pathinfo( $row->get( 'pgitemfilename' ), PATHINFO_EXTENSION ) );

			if ( cbReadDirectory( $newFilePath, '^' . preg_quote( $cleanFileName ) ) ) {
				$query					=	'SELECT COUNT(*)'
										.	"\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_gallery_items' )
										.	"\n WHERE " . $_CB_database->NameQuote( 'user_id' ) . " = " . (int) $row->get( 'userid' )
										.	"\n AND " . $_CB_database->NameQuote( 'value' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $cleanFileName, true ) . '%', false );
				$_CB_database->setQuery( $query );
				if ( $_CB_database->loadResult() ) {
					continue;
				}
			}

			if ( ! is_dir( $newFilesPath ) ) {
				$oldMask				=	@umask( 0 );

				if ( @mkdir( $newFilesPath, 0755, true ) ) {
					@umask( $oldMask );
					@chmod( $newFilesPath, 0755 );

					if ( ! file_exists( $newFilesPath . '/index.html' ) ) {
						@copy( $indexPath, $newFilesPath . '/index.html' );
						@chmod( $newFilesPath . '/index.html', 0755 );
					}
				} else {
					@umask( $oldMask );
				}
			}

			if ( ! file_exists( $newFilesPath . '/.htaccess' ) ) {
				file_put_contents( $newFilesPath . '/.htaccess', 'deny from all' );
			}

			if ( ! is_dir( $newFilePath ) ) {
				$oldMask				=	@umask( 0 );

				if ( @mkdir( $newFilePath, 0755, true ) ) {
					@umask( $oldMask );
					@chmod( $newFilePath, 0755 );

					if ( ! file_exists( $newFilePath . '/index.html' ) ) {
						@copy( $indexPath, $newFilePath . '/index.html' );
						@chmod( $newFilePath . '/index.html', 0755 );
					}
				} else {
					@umask( $oldMask );
				}
			}

			if ( ! @copy( $oldFilePath . '/' . $row->get( 'pgitemfilename' ), $newFilePath . '/' . $newFileName ) ) {
				continue;
			} else {
				@chmod( $newFilePath . '/' . $newFileName, 0755 );
			}

			if ( $type == 'photos' ) {
				if ( ! @copy( $oldFilePath . '/tn' . $row->get( 'pgitemfilename' ), $newFilePath . '/tn' . $newFileName ) ) {
					continue;
				} else {
					@chmod( $newFilePath . '/tn' . $newFileName, 0755 );
				}
			}

			$item						=	new Table( null, '#__comprofiler_plugin_gallery_items', 'id' );

			$item->set( 'user_id', (int) $row->get( 'userid' ) );
			$item->set( 'type', $type );
			$item->set( 'value', $newFileName );
			$item->set( 'folder', 0 );
			$item->set( 'title', $row->get( 'pgitemtitle' ) );
			$item->set( 'description', $row->get( 'pgitemdescription' ) );
			$item->set( 'date', $row->get( 'pgitemdate' ) );
			$item->set( 'published', ( $row->get( 'pgitemapproved', 0 ) ? (int) $row->get( 'pgitempublished', 0 ) : -1 ) );

			if ( ! $item->store() ) {
				@unlink( $newFilePath . '/' . $newFileName );

				if ( $type == 'photos' ) {
					@unlink( $newFilePath . '/tn' . $newFileName );
				}
			}
		}

		$field							=	new FieldTable();

		if ( $field->load( array( 'name' => 'cb_pgtotalquotaitems' ) ) ) {
			$field->set( 'type', 'integer' );
			$field->set( 'tabid', 11 );
			$field->set( 'pluginid', 1 );
			$field->set( 'readonly', 1 );
			$field->set( 'calculated', 0 );
			$field->set( 'sys', 0 );

			$field->store();
		}

		$gallery						=	new PluginTable();

		if ( $gallery->load( array( 'element' => 'cbgallery' ) ) ) {
			$galleryParams				=	new Registry( $gallery->params );

			$galleryParams->set( 'photos_item_limit', 'cb_pgtotalquotaitems' );
			$galleryParams->set( 'files_item_limit', 'cb_pgtotalquotaitems' );

			$gallery->set( 'params', $galleryParams->asJson() );

			$gallery->store();
		}

		ob_start();
		$plgInstaller					=	new cbInstallerPlugin();

		$plgInstaller->uninstall( $plugin->id, 'com_comprofiler' );
		ob_end_clean();
	}
}
function plug_cbgroupjiveevents_install()
{
	global $_CB_database;

	// Grab GJ params to migrate the legacy params:
	$plugin						=	new PluginTable();

	$plugin->load( array( 'element' => 'cbgroupjive' ) );

	$pluginParams				=	new Registry( $plugin->get( 'params' ) );

	if ( $pluginParams->has( 'events_event_content' ) || ( $pluginParams->get( 'events_event_content' ) != null ) ) {
		// Migrate events integration parameters:
		$events					=	new PluginTable();

		$events->load( array( 'element' => 'cbgroupjiveevents' ) );

		$eventsParams			=	new Registry( $events->get( 'params' ) );

		if ( ! $eventsParams->get( 'migrated' ) ) {
			$eventsParams->set( 'groups_events_content_plugins', $pluginParams->get( 'events_event_content' ) );
			$eventsParams->set( 'groups_events_address', $pluginParams->get( 'events_plotting' ) );
			$eventsParams->set( 'groups_events_captcha', $pluginParams->get( 'events_captcha' ) );
			$eventsParams->set( 'groups_events_paging', $pluginParams->get( 'group_tab_paging' ) );
			$eventsParams->set( 'groups_events_limit', $pluginParams->get( 'group_tab_limit' ) );
			$eventsParams->set( 'groups_events_search', $pluginParams->get( 'group_tab_search' ) );
			$eventsParams->set( 'migrated', true );

			$events->set( 'params', $eventsParams->asJson() );

			$events->store();
		}
	}

	$table						=	'#__groupjive_plugin_events';
	$fields						=	$_CB_database->getTableFields( $table );

	if ( isset( $fields[$table]['date'] ) ) {
		$now					=	Application::Database()->getUtcDateTime();

		// Move attending to attendance table:
		$query					=	'SELECT ' . $_CB_database->NameQuote( 'id' )
								.	', ' . $_CB_database->NameQuote( 'attending' )
								.	"\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_events' );
		$_CB_database->setQuery( $query );
		$rows					=	$_CB_database->loadAssocList( 'id', 'attending' );

		$attend					=	array();

		foreach ( $rows as $id => $attending ) {
			foreach ( explode( '|*|', $attending ) as $attendee ) {
				$attendee		=	explode( ':', $attendee );
				$userId			=	( isset( $attendee[0] ) ? (int) $attendee[0] : null );
				$attendance		=	( isset( $attendee[1] ) ? (int) $attendee[1] : null );

				if ( $userId && ( $attendance == 1 ) ) {
					$attend[]	=	'( ' . (int) $userId . ', ' . (int) $id . ', ' . $_CB_database->Quote( $now ) . ' )';
				}
			}
		}

		if ( $attend ) {
			$query				=	'INSERT IGNORE INTO '. $_CB_database->NameQuote( '#__groupjive_plugin_events_attendance' )
								.	' ( '
								.		$_CB_database->NameQuote( 'user_id' )
								.		', ' . $_CB_database->NameQuote( 'event' )
								.		', ' . $_CB_database->NameQuote( 'date' )
								.	' ) VALUES ' . implode( ', ', $attend );
			$_CB_database->setQuery( $query );
			$_CB_database->query();
		}

		// Mode date to start:
		$query					=	'UPDATE '. $_CB_database->NameQuote( '#__groupjive_plugin_events' )
								.	"\n SET " . $_CB_database->NameQuote( 'start' ) . " = " . $_CB_database->NameQuote( 'date' );
		$_CB_database->setQuery( $query );
		$_CB_database->query();

		// Remove the old columns:
		$_CB_database->dropColumn( $table, 'latitude' );
		$_CB_database->dropColumn( $table, 'longitude' );
		$_CB_database->dropColumn( $table, 'attending' );
		$_CB_database->dropColumn( $table, 'date' );
	}
}
Ejemplo n.º 19
0
	/**
	 * store default notifications
	 *
	 * @param \CB\Plugin\GroupJive\Table\UserTable $row
	 * @param Registry                             $notifications
	 */
	public function storeNotifications( $row, &$notifications )
	{
		$notifications->set( 'event_new', $this->params->get( 'notifications_default_event_new', 0 ) );
		$notifications->set( 'event_edit', $this->params->get( 'notifications_default_event_edit', 0 ) );
		$notifications->set( 'event_approve', $this->params->get( 'notifications_default_event_approve', 0 ) );
		$notifications->set( 'event_attend', $this->params->get( 'notifications_default_event_attend', 0 ) );
		$notifications->set( 'event_unattend', $this->params->get( 'notifications_default_event_unattend', 0 ) );
	}
Ejemplo n.º 20
0
	/**
	 * Returns a provider button
	 *
	 * @param string $provider
	 * @param int    $horizontal
	 * @return null|string
	 */
	public function getButton( $provider, $horizontal = 1 )
	{
		global $_CB_framework;

		if ( ! ( $provider && isset( $this->providers[$provider] ) ) ) {
			return null;
		}

		$fieldName					=	$this->providers[$provider]['field'];
		$siteName					=	$this->providers[$provider]['name'];
		$iconClass					=	$this->providers[$provider]['icon'];
		$buttonClass				=	$this->providers[$provider]['button'];
		$user						=	CBuser::getMyUserDataInstance();
		$style						=	(int) $this->params->get( $provider . '_button_style', 2, GetterInterface::INT );

		if ( $style == 1 ) {
			$horizontal				=	1;
		}

		static $returnUrl			=	null;

		if ( ! isset( $returnUrl ) ) {
			$returnUrl				=	$this->input->get( 'return', null, GetterInterface::BASE64 );

			if ( $returnUrl ) {
				$returnUrl			=	base64_decode( $returnUrl );
			} else {
				$isHttps			=	( isset( $_SERVER['HTTPS'] ) && ( ! empty( $_SERVER['HTTPS'] ) ) && ( $_SERVER['HTTPS'] != 'off' ) );
				$returnUrl			=	'http' . ( $isHttps ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST'];

				if ( ( ! empty( $_SERVER['PHP_SELF'] ) ) && ( ! empty( $_SERVER['REQUEST_URI'] ) ) ) {
					$returnUrl		.=	$_SERVER['REQUEST_URI'];
				} else {
					$returnUrl		.=	$_SERVER['SCRIPT_NAME'];

					if ( isset( $_SERVER['QUERY_STRING'] ) && ( ! empty( $_SERVER['QUERY_STRING'] ) ) ) {
						$returnUrl	.=	'?' . $_SERVER['QUERY_STRING'];
					}
				}
			}

			$returnUrl				=	cbUnHtmlspecialchars( preg_replace( '/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/', '""', preg_replace( '/eval\((.*)\)/', '', htmlspecialchars( urldecode( $returnUrl ) ) ) ) );

			if ( preg_match( '/index\.php\?option=com_comprofiler&view=login|index\.php\?option=com_comprofiler&view=pluginclass&plugin=cbconnect/', $returnUrl ) ) {
				$returnUrl			=	'index.php';
			}

			$returnUrl				=	base64_encode( $returnUrl );
		}

		$return						=	null;

		if ( $this->params->get( $provider . '_enabled', false, GetterInterface::BOOLEAN ) ) {
			if ( $user->get( 'id' ) ) {
				if ( $this->params->get( $provider . '_link', true, GetterInterface::BOOLEAN ) && ( ! $user->get( $fieldName ) ) ) {
					$link			=	$this->params->get( $provider . '_button_link', null, GetterInterface::STRING );

					$return			=	'<button class="cbConnectButton cbConnectButton' . ucfirst( $provider ) . ' btn btn-' . $buttonClass . ' btn-sm' . ( ! $horizontal ? ' btn-block' : null ) . '" onclick="window.location=\'' . $_CB_framework->pluginClassUrl( $this->plugin->element, false, array( 'provider' => $provider, 'action' => 'authenticate', 'return' => $returnUrl ) ) . '\'; return false;" title="' . htmlspecialchars( CBTxt::T( 'LINK_YOUR_SITENAME_ACCOUNT', 'Link your [sitename] account', array( '[sitename]' => $siteName ) ) ) . '">'
									.		( in_array( $style, array( 1, 2 ) ) ? '<span class="fa fa-' . $iconClass . ' fa-lg' . ( $style != 1 ? ' cbConnectButtonPrefix' : null ) . '"></span>' : null )
									.		( in_array( $style, array( 2, 3 ) ) ? ( $link ? $link : CBTxt::T( 'LINK_WITH_SITENAME', 'Link with [sitename]', array( '[sitename]' => $siteName ) ) ) : null )
									.	'</button>'
									.	( $horizontal ? ' ' : null );
				}
			} else {
				$signin				=	$this->params->get( $provider . '_button_signin', null, GetterInterface::STRING );

				$return				=	'<button class="cbConnectButton cbConnectButton' . ucfirst( $provider ) . ' btn btn-' . $buttonClass . ' btn-sm' . ( ! $horizontal ? ' btn-block' : null ) . '" onclick="window.location=\'' . $_CB_framework->pluginClassUrl( $this->plugin->element, false, array( 'provider' => $provider, 'action' => 'authenticate', 'return' => $returnUrl ) ) . '\'; return false;" title="' . htmlspecialchars( CBTxt::T( 'LOGIN_WITH_YOUR_SITENAME_ACCOUNT', 'Login with your [sitename] account', array( '[sitename]' => $siteName ) ) ) . '">'
									.		( in_array( $style, array( 1, 2 ) ) ? '<span class="fa fa-' . $iconClass . ' fa-lg' . ( $style != 1 ? ' cbConnectButtonPrefix' : null ) . '"></span>' : null )
									.		( in_array( $style, array( 2, 3 ) ) ? ( $signin ? $signin : CBTxt::T( 'SIGN_IN_WITH_SITENAME', 'Sign in with [sitename]', array( '[sitename]' => $siteName ) ) ) : null )
									.	'</button>'
									.	( $horizontal ? ' ' : null );
			}
		}

		return $return;
	}
Ejemplo n.º 21
0
	/**
	 * store default notifications
	 *
	 * @param \CB\Plugin\GroupJive\Table\UserTable $row
	 * @param Registry                             $notifications
	 */
	public function storeNotifications( $row, &$notifications )
	{
		$notifications->set( 'photo_new', $this->params->get( 'notifications_default_photo_new', 0 ) );
		$notifications->set( 'photo_approve', $this->params->get( 'notifications_default_photo_approve', 0 ) );
	}
Ejemplo n.º 22
0
/**
 * Commented CBT calls for language parser pickup: Moved to cb.core.php so they get picked-up in front-end language file and not in backend one.
 */
function loadSampleData()
{
    global $_CB_Backend_Title;
    @set_time_limit(240);
    $_CB_Backend_Title = array(0 => array('fa fa-wrench', CBTxt::T('TOOLS_SAMPLE_DATA_TITLE', 'CB Tools: Sample Data: Results')));
    $return = null;
    $affected = false;
    $tab = new TabTable();
    $tab->load(array('title' => '_UE_ADDITIONAL_INFO_HEADER'));
    if (!$tab->tabid) {
        $affected = true;
        $tab->set('title', '_UE_ADDITIONAL_INFO_HEADER');
        $tab->set('displaytype', 'menunested');
        $tab->set('position', 'canvas_main_middle');
        $tab->set('viewaccesslevel', 1);
        $tab->set('enabled', 1);
        $tab->set('ordering', 1);
        if ($tab->getError() || !$tab->store()) {
            $return .= '<div class="form-group cb_form_line clearfix text-danger">' . CBTxt::T('TOOLS_SAMPLE_DATA_TAB_NOT_OK', 'Tab [title] failed to add. Error: [error]', array('[title]' => $tab->get('title'), '[error]' => $tab->getError())) . '</div>';
        }
    }
    if ($affected) {
        $return .= '<div class="form-group cb_form_line clearfix text-success">' . CBTxt::T('TOOLS_SAMPLE_DATA_TAB_OK', 'Tab Added Successfully!') . '</div>';
    }
    $affected = false;
    $fields = array('cb_website' => array('title' => '_UE_Website', 'type' => 'webaddress', 'registration' => 0, 'ordering' => 1), 'cb_location' => array('title' => '_UE_Location', 'type' => 'text', 'maxlength' => 50, 'size' => 25, 'registration' => 0, 'ordering' => 2), 'cb_occupation' => array('title' => '_UE_Occupation', 'type' => 'text', 'registration' => 0, 'ordering' => 3), 'cb_interests' => array('title' => '_UE_Interests', 'type' => 'text', 'registration' => 0, 'ordering' => 4), 'cb_company' => array('title' => '_UE_Company', 'type' => 'text', 'ordering' => 5), 'cb_city' => array('title' => '_UE_City', 'type' => 'text', 'ordering' => 6), 'cb_state' => array('title' => '_UE_State', 'type' => 'text', 'maxlength' => 10, 'size' => 4, 'ordering' => 7), 'cb_zipcode' => array('title' => '_UE_ZipCode', 'type' => 'text', 'ordering' => 8), 'cb_country' => array('title' => '_UE_Country', 'type' => 'text', 'ordering' => 9), 'cb_address' => array('title' => '_UE_Address', 'type' => 'text', 'ordering' => 10), 'cb_phone' => array('title' => '_UE_PHONE', 'type' => 'text', 'ordering' => 11), 'cb_fax' => array('title' => '_UE_FAX', 'type' => 'text', 'ordering' => 12));
    foreach ($fields as $fieldName => $fieldSettings) {
        $field = new FieldTable();
        $field->load(array('name' => $fieldName));
        if (!$field->fieldid) {
            $affected = true;
            $field->set('name', $fieldName);
            $field->set('registration', 1);
            $field->set('profile', 1);
            $field->set('edit', 1);
            $field->set('published', 1);
            foreach ($fieldSettings as $column => $value) {
                $field->set($column, $value);
            }
            $field->set('tabid', $tab->tabid);
            $field->set('pluginid', 1);
            if ($field->getError() || !$field->store()) {
                $return .= '<div class="form-group cb_form_line clearfix text-danger">' . CBTxt::T('TOOLS_SAMPLE_DATA_FIELD_NOT_OK', 'Field [name] failed to add. Error: [error]', array('[name]' => $field->get('name'), '[error]' => $field->getError())) . '</div>';
            }
        }
    }
    if ($affected) {
        $return .= '<div class="form-group cb_form_line clearfix text-success">' . CBTxt::T('TOOLS_SAMPLE_DATA_FIELD_OK', 'Fields Added Successfully!') . '</div>';
    }
    $affected = false;
    $list = new ListTable();
    $list->load(array('title' => 'Members List'));
    if (!$list->listid) {
        $affected = true;
        $list->set('title', 'Members List');
        $list->set('viewaccesslevel', 1);
        $list->set('usergroupids', '1|*|6|*|7|*|2|*|3|*|4|*|5|*|8');
        $list->set('default', 1);
        $list->set('published', 1);
        $list->set('ordering', 1);
        $listParams = new Registry();
        $listParams->set('sort_mode', '0');
        $listParams->set('basic_sort', array(array('column' => 'username', 'direction' => 'ASC')));
        $listParams->set('columns', array(array('title' => 'User', 'size' => '3', 'fields' => array(array('field' => '17', 'display' => '4'), array('field' => '29', 'display' => '4'), array('field' => '42', 'display' => '4'), array('field' => '26', 'display' => '4'))), array('title' => 'Info', 'size' => '9', 'fields' => array(array('field' => '27', 'display' => '1'), array('field' => '49', 'display' => '1'), array('field' => '28', 'display' => '1')))));
        $listParams->set('list_grid_layout', '1');
        $list->set('params', $listParams->asJson());
        if ($list->getError() || !$list->store()) {
            $return .= '<div class="form-group cb_form_line clearfix text-danger">' . CBTxt::T('TOOLS_SAMPLE_DATA_LIST_NOT_OK', 'List [title] failed to add. Error: [error]', array('[title]' => $list->get('title'), '[error]' => $tab->getError())) . '</div>';
        }
    }
    if ($affected) {
        $return .= '<div class="form-group cb_form_line clearfix text-success">' . CBTxt::T('TOOLS_SAMPLE_DATA_LIST_OK', 'List Added Successfully!') . '</div>';
    }
    if (!$return) {
        $return .= '<div class="form-group cb_form_line clearfix">' . CBTxt::T('TOOLS_SAMPLE_DATA_ALREADY_CONFIGURED', 'Sample Data is already loaded!') . '</div>';
    }
    echo $return;
}
Ejemplo n.º 23
0
	/**
	 * @param UserTable  $user
	 * @param GroupTable $group
	 * @param array      $counters
	 * @return array|null
	 */
	public function getTopics( $user, &$group, &$counters )
	{
		global $_CB_framework, $_CB_database;

		$categoryId					=	(int) $group->params()->get( 'forum_id' );

		if ( ( ! $categoryId ) || ( ! $group->params()->get( 'forums', 1 ) ) || ( $group->category()->get( 'id' ) && ( ! $group->category()->params()->get( 'forums', 1 ) ) ) ) {
			return null;
		}

		CBGroupJive::getTemplate( 'forums', true, true, $this->plugin->element );

		$limit						=	(int) $this->params->get( 'groups_forums_limit', 15 );
		$limitstart					=	$_CB_framework->getUserStateFromRequest( 'gj_group_forums_limitstart{com_comprofiler}', 'gj_group_forums_limitstart' );
		$search						=	$_CB_framework->getUserStateFromRequest( 'gj_group_forums_search{com_comprofiler}', 'gj_group_forums_search' );
		$where						=	null;

		if ( $search && $this->params->get( 'groups_forums_search', 1 ) ) {
			$where					.=	'( m.' . $_CB_database->NameQuote( 'subject' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false )
									.	' OR t.' . $_CB_database->NameQuote( 'message' ) . ' LIKE ' . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $search, true ) . '%', false ) . ' )';
		}

		$searching					=	( $where ? true : false );

		$params						=	array(	'starttime' => -1,
												'where' => $where
											);

		$posts						=	\KunenaForumMessageHelper::getLatestMessages( $categoryId, 0, 0, $params );
		$total						=	array_shift( $posts );

		if ( ( ! $total ) && ( ! $searching ) && ( ! CBGroupJive::canCreateGroupContent( $user, $group, 'forums' ) ) ) {
			return null;
		}

		$pageNav					=	new \cbPageNav( $total, $limitstart, $limit );

		$pageNav->setInputNamePrefix( 'gj_group_forums_' );

		switch( (int) $this->params->get( 'groups_forums_orderby', 2 ) ) {
			case 1:
				$params['orderby']	=	'm.' . $_CB_database->NameQuote( 'time' ) . ' ASC';
				break;
		}

		if ( $this->params->get( 'groups_forums_paging', 1 ) ) {
			$posts					=	\KunenaForumMessageHelper::getLatestMessages( $categoryId, (int) $pageNav->limitstart, (int) $pageNav->limit, $params );
			$posts					=	array_pop( $posts );
		} else {
			$posts					=	array_pop( $posts );
		}

		$rows						=	array();

		/** @var \KunenaForumMessage[] $posts */
		foreach ( $posts as $post ) {
			$row					=	new PostTable();

			$row->post( $post );

			$rows[]					=	$row;
		}

		$input						=	array();

		$input['search']			=	'<input type="text" name="gj_group_forums_search" value="' . htmlspecialchars( $search ) . '" onchange="document.gjGroupForumsForm.submit();" placeholder="' . htmlspecialchars( CBTxt::T( 'Search Posts...' ) ) . '" class="form-control" />';

		CBGroupJive::preFetchUsers( $rows );

		$group->set( '_forums', $pageNav->total );

		return array(	'id'		=>	'forums',
						'title'		=>	CBTxt::T( 'Forums' ),
						'content'	=>	\HTML_groupjiveForums::showForums( $rows, $pageNav, $searching, $input, $counters, $group, $user, $this )
					);
	}
Ejemplo n.º 24
0
 /**
  * Handles the backend plugin edition
  *
  * @param  string           $option
  * @param  string           $action
  * @param  SimpleXMLElement $element
  * @param  string           $mode
  * @return string                        HTML
  *
  * @throws \LogicException
  */
 public function drawView($option, $action, $element, $mode)
 {
     global $_CB_Backend_Menu;
     $ui = $this->clientId == 1 ? 2 : 1;
     $context = new Context();
     $pluginParams = $context->getParams();
     $interfaceUi = $ui == 2 ? 'admin' : 'frontend';
     $adminActionsModel = $element->getChildByNameAttr('actions', 'ui', $interfaceUi);
     if (!$adminActionsModel) {
         $adminActionsModel = $element->getChildByNameAttr('actions', 'ui', 'all');
     }
     if (!$adminActionsModel) {
         throw new \LogicException('No ' . $interfaceUi . ' actions defined in XML');
     }
     // Check permission if specified:
     if (!Access::authorised($adminActionsModel)) {
         return CBTxt::T("Access to these actions is not authorized by the permissions of your user groups.");
     }
     // General-purpose extenders:
     $extenders = $adminActionsModel->xpath('extend');
     /** @var SimpleXMLElement[] $extenders */
     foreach ($extenders as $k => $extends) {
         $error = RegistryEditView::extendXMLnode($extenders[$k], $element, null, $context->getPluginObject());
         if ($error) {
             echo $error;
         }
     }
     $found = false;
     $actionPath = array();
     if ($action) {
         $actionsModel = $adminActionsModel->getChildByNameAttr('action', 'name', $action);
         $found = $actionsModel != null;
         if ($found) {
             $requests = explode(' ', $actionsModel->attributes('request'));
             $values = explode(' ', $actionsModel->attributes('action'));
             $actionPath = array();
             for ($i = 0, $n = count($requests); $i < $n; $i++) {
                 $actionPath[$requests[$i]] = $values[$i];
             }
         }
     }
     if (!$found) {
         // EVENT: select the event from URL and compute the selected $actionPath
         $found = false;
         $actionsModel = null;
         foreach ($adminActionsModel->children() as $actionsModel) {
             /** @var SimpleXMLElement $actionsModel */
             $request = $actionsModel->attributes('request');
             if ($request) {
                 $requests = explode(' ', $request);
                 $values = explode(' ', $actionsModel->attributes('action'));
                 $actionPath = array();
                 for ($i = 0, $n = count($requests); $i < $n; $i++) {
                     $actionPath[$requests[$i]] = $this->input->get($requests[$i], null, GetterInterface::STRING);
                     // Temporary fix for older versions of CBSubs before CBSubs 4.0.0 stable to avoid warnings on ajax version checks:
                     if ($requests[$i] === 'view' && $actionPath['view'] === null) {
                         $actionPath['view'] = $this->input->get('task', null, GetterInterface::STRING);
                     }
                     if ($actionPath[$requests[$i]] != $values[$i]) {
                         break;
                     }
                 }
                 if ($i == $n) {
                     $found = true;
                     break;
                 }
             }
         }
     }
     if (!$found) {
         $actionPath = array();
         // try finding first default one:
         if ($ui == 2) {
             $actionsModel = $adminActionsModel->getChildByNameAttr('action', 'request', '');
         }
         if (!isset($actionsModel)) {
             return CBTxt::T('AHAWOW_REQUESTED_ACTION_NOT_DEFINED_IN_XML', "Requested action '[ACTION]' not defined in XML.", array('[ACTION]' => htmlspecialchars($action)));
         }
     }
     // Check permission if specified:
     if (!isset($actionsModel) || !Access::authorised($actionsModel)) {
         return CBTxt::T("This action is not authorized by the permissions of your user groups.");
     }
     if (!isset($actionPath['view'])) {
         $actionPath['view'] = $ui == 2 ? 'editPlugin' : '';
         //TODO: 2nd should come from target routing
     } elseif ($actionPath['view'] != 'editPlugin') {
         $actionPath['act'] = '';
     }
     // EVENT: fetch the input parameters from URL:
     $parametersNames = explode(' ', $actionsModel->attributes('requestparameters'));
     $parametersValues = array();
     foreach ($parametersNames as $paraNam) {
         $parametersValues[$paraNam] = null;
         if (strpos($paraNam, '[') === false) {
             if (trim($paraNam)) {
                 $parametersValues[$paraNam] = $this->input->get($paraNam, '', GetterInterface::STRING);
             }
         } else {
             $matches = null;
             preg_match_all('/(.*)(?:\\[(.*)\\])+/', $paraNam, $matches);
             if (is_array($matches) && count($matches) >= 3 && count($matches[2]) >= 1) {
                 $parametersValues[$paraNam] = $this->input->get($matches[1][0] . '.' . $matches[2][0], null, GetterInterface::STRING);
             }
         }
     }
     $keyValues = array();
     // Action-specific general extenders:
     $extenders = $adminActionsModel->xpath('actionspecific/extend');
     /** @var SimpleXMLElement[] $extenders */
     foreach ($extenders as $k => $extends) {
         $error = RegistryEditView::extendXMLnode($extenders[$k], $element, $actionsModel, $context->getPluginObject());
         if ($error) {
             echo $error;
         }
     }
     // First extend what can be extended so the showview's below have a complete XML tree:
     /** @var $actionItem SimpleXMLElement */
     foreach ($actionsModel->xpath('extend') as $actionItem) {
         $error = RegistryEditView::extendXMLnode($actionItem, $element, $actionsModel, $context->getPluginObject());
         if ($error) {
             echo $error;
         }
     }
     /** @var $actionItem SimpleXMLElement */
     foreach ($actionsModel->children() as $actionItem) {
         // CONTROLLER: select the controller:
         switch ($actionItem->getName()) {
             case 'extend':
                 // Treated just above.
                 break;
             case 'showview':
                 $viewName = $actionItem->attributes('view');
                 $showviewType = $actionItem->attributes('type');
                 $viewMode = $actionItem->attributes('mode');
                 // MODEL: load data to view:
                 $dataModel = $actionItem->getElementByPath('data');
                 if ($dataModel) {
                     $dataModelType = $dataModel->attributes('type');
                     $cbDatabase = $this->db;
                     if (in_array($dataModelType, array('sql:row', 'sql:multiplerows', 'sql:field', 'parameters'))) {
                         $xmlsql = new XmlQuery($cbDatabase, null, $pluginParams);
                         $data = $xmlsql->loadObjectFromData($dataModel);
                         if ($data === null) {
                             return 'showview::sql:row: load failed: ' . $cbDatabase->getErrorMsg();
                         }
                         $dataModelValueName = $dataModel->attributes('value');
                         $dataModelValueType = $dataModel->attributes('valuetype');
                         // if the value of key is a parameter name, replace it with the corresponding parameter:
                         $dataModelValueTypeArray = explode(':', $dataModelValueType);
                         if ($dataModelValueTypeArray[0] == 'request') {
                             if (isset($parametersValues[$dataModelValueName])) {
                                 $dataModelValue = $parametersValues[$dataModelValueName];
                                 // database escaping to int is done at request time
                                 $keyValues[$dataModelValueName] = $dataModelValue;
                                 unset($parametersValues[$dataModelValueName]);
                             } else {
                                 echo sprintf('showview::sql::row %s: request %s not in parameters of action.', $dataModel->attributes('name'), $dataModelValueName);
                             }
                         }
                         if ($dataModelType == 'sql:field') {
                             $data = new Registry($data);
                         }
                     } elseif ($dataModelType == 'class') {
                         $dataModelClass = $dataModel->attributes('class');
                         $dataModelValue = $dataModel->attributes('value');
                         $dataModelValueName = $dataModelValue;
                         $dataModelValueType = $dataModel->attributes('valuetype');
                         $dataModelValueTypeArray = explode(':', $dataModelValueType);
                         if ($dataModelValueTypeArray[0] == 'request') {
                             if (isset($parametersValues[$dataModelValueName])) {
                                 $dataModelValue = $parametersValues[$dataModelValueName];
                                 $keyValues[$dataModelValueName] = $dataModelValue;
                                 unset($parametersValues[$dataModelValueName]);
                             } else {
                                 echo sprintf('showview::sql::row %s: request %s not in parameters of action.', $dataModel->attributes('name'), $dataModelValue);
                             }
                         }
                         if (strpos($dataModelClass, '::') === false) {
                             $data = new $dataModelClass($cbDatabase);
                             // normal clas="className"
                             /** @var $data TableInterface */
                             $data->load($dataModelValue);
                         } else {
                             $dataModelSingleton = explode('::', $dataModelClass);
                             // class object loader from singleton: class="loaderClass::loadStaticMethor" with 1 parameter, the key value.
                             if (is_callable($dataModelSingleton)) {
                                 if (is_callable(array($dataModelSingleton[0], 'getInstance'))) {
                                     $instance = call_user_func_array(array($dataModelSingleton[0], 'getInstance'), array(&$cbDatabase));
                                     $rows = call_user_func_array(array($instance, $dataModelSingleton[1]), array($dataModelValue));
                                 } else {
                                     $rows = call_user_func_array($dataModelSingleton, array($dataModelValue));
                                 }
                             } else {
                                 echo sprintf('showview::class %s: missing singleton class creator %s.', $dataModel->attributes('name'), $dataModelClass);
                                 $std = new \stdClass();
                                 $rows = array($std);
                             }
                             $data = $rows[0];
                         }
                     } else {
                         $data = null;
                         echo 'showview: Data model type ' . $dataModelType . ' is not implemented !';
                     }
                 } else {
                     if ($this->_data instanceof TableInterface || $this->_data instanceof \comprofilerDBTable) {
                         $data = $this->_data;
                         $dataModelType = 'sql:row';
                     } elseif ($this->_data instanceof ParamsInterface) {
                         $data = $this->_data;
                         $dataModelType = 'sql:row';
                     } else {
                         $data = null;
                         $dataModelType = null;
                     }
                 }
                 // VIEW: select view:
                 $allViewsModels = $element->getElementByPath('views');
                 if ($viewName && (!$showviewType || $showviewType == 'view')) {
                     ////// $viewModel		= $allViewsModels->getChildByNameAttributes( 'view', array( 'name' => $viewName ) );
                     $xpathUi = '/*/views/view[@ui="' . $interfaceUi . '" and @name="' . $viewName . '"]';
                     $xpathAll = '/*/views/view[@ui="all" and @name="' . $viewName . '"]';
                     $viewModel = $element->xpath($xpathUi);
                     if (!$viewModel) {
                         $viewModel = $element->xpath($xpathAll);
                     }
                     if (!$viewModel) {
                         $viewModel = RegistryEditView::xpathWithAutoLoad($element, $xpathUi);
                     }
                     if (!$viewModel) {
                         $viewModel = RegistryEditView::xpathWithAutoLoad($element, $xpathAll);
                     }
                     /*
                     						if ( ! $viewModel ) {
                     							$viewModel		=	RegistryEditView::xpathWithAutoLoad( $element, '/ * / views/view[not(@ui) and @name="' . $viewName . '"]' );
                     						}
                     */
                     if ($viewModel) {
                         $viewModel = $viewModel[0];
                     } else {
                         return 'XML:showview: View ' . $viewName . ' not defined in ui ' . $interfaceUi . ' in XML';
                     }
                 } elseif ($showviewType == 'xml') {
                     // e.g.: <showview name="gateway_paymentstatus_information" mode="view" type="xml" file="processors/{payment_method}/edit.gateway" path="/*/views/view[@name=&quot;paymentstatusinformation&quot;]" mandatory="false" />
                     $fromNode = $actionItem->attributes('path');
                     $fromFile = $actionItem->attributes('file');
                     if ($fromNode && $fromFile !== null) {
                         // $this->substituteName( $fromFile, true );
                         // $this->substituteName( $fromNode, false );
                         $fromFile = $context->getPluginPath() . '/' . $fromFile . '.xml';
                         if ($fromFile === '' || is_readable($fromFile)) {
                             if ($fromFile === '') {
                                 $fromRoot = $element;
                             } else {
                                 $fromRoot = new SimpleXMLElement($fromFile, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0), true);
                             }
                             $viewModel = $fromRoot->xpath($fromNode);
                             if (!$viewModel) {
                                 trigger_error('Admin:showview: View ' . $viewName . ': file ' . $fromFile . ', path: ' . $fromNode . ' does not exist or is empty.', E_USER_NOTICE);
                             }
                             $viewModel = $viewModel[0];
                         } else {
                             throw new \LogicException('Admin:showview: View ' . $viewName . ': file ' . $fromFile . ' does not exist or is not readable.');
                         }
                     } else {
                         throw new \LogicException('Admin:showview: View ' . $viewName . ' file or path not defined..', E_USER_NOTICE);
                     }
                 } else {
                     throw new \LogicException('Admin:showview: View ' . $viewName . ' not of supported type.', E_USER_NOTICE);
                 }
                 $viewUi = $viewModel->attributes('ui');
                 if ($viewUi & $viewUi != 'all' && $viewUi != $interfaceUi) {
                     throw new \LogicException('showview: View ' . $viewName . ' not allowed for ' . $interfaceUi);
                 }
                 $extendedParser = $allViewsModels->getElementByPath('extendxmlparser');
                 $actionPath = array_merge($actionPath, $keyValues);
                 $options = array_merge($this->getBaseOptions(), $actionPath, $parametersValues);
                 if ($ui == 2) {
                     $options = array_merge($options, $actionPath, $parametersValues);
                 }
                 $cbprevstate = $this->input->get('cbprevstate', null, GetterInterface::STRING);
                 $params = new RegistryEditController($this->input, $this->db, new Registry(), $viewModel, $element, $context->getPluginObject());
                 $displayData = $this->bindInput($viewMode, $data);
                 // Set the parameters with the $displayData :
                 $registry = new Registry();
                 $registry->load($displayData);
                 $registry->setStorage($displayData);
                 $params->setRegistry($registry);
                 $params->setPluginParams($pluginParams);
                 $params->setOptions($options);
                 if ($extendedParser) {
                     $params->setExtendedViewParser($extendedParser);
                 }
                 $extenders = $allViewsModels->xpath('extend');
                 foreach ($extenders as $extends) {
                     RegistryEditView::extendXMLnode($extends, $element, $actionsModel, $context->getPluginObject());
                 }
                 $viewType = $viewModel->attributes('type');
                 switch ($viewType) {
                     case 'params':
                         if ($mode == 'edit') {
                             if ($viewMode == 'edit' || $viewMode == 'show') {
                                 $viewTypeMode = $viewMode == 'edit' ? 'param' : 'view';
                                 if ($ui == 2) {
                                     $htmlOutput = $this->input->get('no_html', 0, GetterInterface::COMMAND) != 1 && $this->input->get('format', null, GetterInterface::COMMAND) != 'raw';
                                     ActionViewAdmin::editPluginView($options, $actionPath, $viewModel, $displayData, $params, $context->getPluginObject(), $viewTypeMode, $cbprevstate, $htmlOutput);
                                     $settings = null;
                                     $html = null;
                                 } else {
                                     /** @global \stdClass $_CB_Backend_Menu   : 'show' : only displays close button, 'edit' : special close button */
                                     global $_CB_Backend_Menu;
                                     $_CB_Backend_Menu = new \stdClass();
                                     $html = '';
                                     outputCbTemplate();
                                     outputCbJs();
                                     // $_CB_framework->outputCbJQuery( '' );
                                     initToolTip();
                                     $htmlFormatting = $viewModel->attributes('viewformatting');
                                     if (!$htmlFormatting) {
                                         global $ueConfig;
                                         if (isset($ueConfig['use_divs']) && $ueConfig['use_divs'] == 1) {
                                             $htmlFormatting = 'div';
                                         } else {
                                             $htmlFormatting = 'table';
                                         }
                                     }
                                     $settings = $params->draw(null, null, null, null, null, null, false, $viewTypeMode, $htmlFormatting);
                                 }
                                 if ($ui == 2) {
                                     $_CB_Backend_Menu->mode = $viewMode;
                                     // Implemented in lower level in RegistryEditView:  $toolbarMenu = $viewModel->getElementByPath( 'toolbarmenu' );
                                 }
                                 if ($ui != 2) {
                                     $actionView = new ActionView();
                                     $buttonSaveText = $actionsModel->attributes('label');
                                     if (!$buttonSaveText) {
                                         $buttonSaveText = 'Save';
                                     }
                                     $buttonSaveText = CBTxt::Th($buttonSaveText);
                                     //	CBTxt::Th("Save"); For translation strings extraction
                                     $warning = null;
                                     if ($viewTypeMode == 'param') {
                                         $settings .= '<div class="cbControlButtonsLine">' . "\n\t" . '<span class="cb_button_wrapper">' . '<button type="submit" name="actbutton" value="' . 'save' . $action . '" class="button cbregButton cbregSaveButton">' . $buttonSaveText . '</button>' . '</span>' . "\n\t" . '</div>' . "\n";
                                         $postedActionPath = $actionPath;
                                         unset($postedActionPath['view']);
                                         $formHiddens = array_merge($this->getBaseOptions(), array('act' => 'save' . $action), $postedActionPath);
                                     } else {
                                         $formHiddens = null;
                                     }
                                     $html .= $actionView->drawForm($settings, $warning, $formHiddens, array_merge($this->_getParams, array('act' => $action)), RegistryEditView::buildClasses($viewModel));
                                     return $html;
                                 }
                             } else {
                                 echo 'showview::params: mode is ' . $mode . ' but view mode is ' . $viewMode . ' instead of edit.';
                             }
                         } elseif (in_array($mode, array('apply', 'save', 'savenew', 'savecopy'))) {
                             $this->savePluginView($options, $actionPath, $keyValues, $parametersValues, $viewModel, $data, $params, $mode, $dataModelType, $context->getPluginObject(), $dataModel, $pluginParams, $cbprevstate, $ui);
                             if ($ui == 2 && $mode == 'apply') {
                                 // We arrive here only in case of saving error, as redirect (performed in savePluginView) would loose the inputs:
                                 return $this->drawView($option, $action, $element, 'edit');
                             }
                         } else {
                             echo 'showview::params: view type params mode ' . $mode . ' is not implemented !';
                         }
                         break;
                     default:
                         echo 'showview::not-params: type of view ' . $viewType . ' is not implemented !';
                         break;
                 }
                 break;
             default:
                 echo 'action::not-showview: child xml element "' . $actionItem->getName() . '" of action is not implemented !';
                 break;
         }
     }
     return null;
 }
 /**
  * @param ListTable     $row
  * @param UserTable[]   $users
  * @param array         $columns
  * @param FieldTable[]  $fields
  * @param array         $input
  * @param string|null   $search
  * @param int           $searchmode
  * @param cbPageNav     $pageNav
  * @param UserTable     $myUser
  * @param FieldTable[]  $searchableFields
  * @param stdClass      $searchValues
  * @param cbTabs        $tabs
  * @param string|null   $errorMsg
  * @param bool          $listAll
  * @param int           $random
  */
 static function usersList(&$row, &$users, &$columns, &$fields, &$input, $search, $searchmode, $pageNav, &$myUser, &$searchableFields, &$searchValues, &$tabs, $errorMsg, $listAll = true, $random = 0)
 {
     global $_CB_framework, $_PLUGINS, $_POST, $_GET, $_REQUEST;
     $params = new Registry($row->params);
     // The Itemid for this userlist; kept for trigger B/C:
     $Itemid = getCBprofileItemid(null, 'userslist', '&listid=' . (int) $row->listid);
     $results = $_PLUGINS->trigger('onBeforeDisplayUsersList', array(&$row, &$users, &$columns, &$fields, &$input, $row->listid, &$search, &$Itemid, 1));
     // $uid = 1
     // Plugin content divided by location:
     $pluginAdditions = array('search', 'header', 'footer');
     $pluginAdditions['search'] = array();
     $pluginAdditions['header'] = array();
     $pluginAdditions['footer'] = array();
     if (is_array($results) && count($results) > 0) {
         foreach ($results as $res) {
             if (is_array($res)) {
                 foreach ($res as $k => $v) {
                     $pluginAdditions[$k][] = $v;
                 }
             }
         }
     }
     outputCbTemplate(1);
     outputCbJs();
     cbValidator::loadValidation();
     $cbTemplate = HTML_comprofiler::_cbTemplateLoad();
     if ($errorMsg) {
         $_CB_framework->enqueueMessage($errorMsg, 'error');
     }
     // Page title and pathway:
     $listTitleHtml = cbReplaceVars($row->title, $myUser);
     $listTitleNoHtml = strip_tags(cbReplaceVars($row->title, $myUser, false, false));
     $listDescription = cbReplaceVars($row->description, $myUser);
     $_CB_framework->setPageTitle($listTitleNoHtml);
     $_CB_framework->appendPathWay($listTitleHtml);
     // Add row click JS:
     if ($params->get('allow_profilelink', 1)) {
         $allowProfileLink = true;
     } else {
         $allowProfileLink = false;
     }
     $js = "var cbUserURLs = [];";
     if (is_array($users) && $allowProfileLink) {
         // Ensures the jQuery array index matches the same as HTML ID index (e.g. cbU0, cbU1):
         $index = 0;
         foreach ($users as $user) {
             $js .= "cbUserURLs[{$index}] = '" . addslashes($_CB_framework->userProfileUrl((int) $user->id, false)) . "';";
             $index++;
         }
     }
     $js .= "\$( '.cbUserListRow' ).click( function( e ) {" . "if ( ! ( \$( e.target ).is( 'a' ) || ( \$( e.target ).is( 'img' ) && \$( e.target ).parent().is( 'a' ) ) || \$( e.target ).hasClass( 'cbClicksInside' ) || ( \$( e.target ).parents( '.cbClicksInside' ).length > 0 ) || ( \$( this ).attr( 'id' ) == '' ) ) ) {" . "var index = \$( this ).prop( 'id' ).substr( 3 );";
     if ($allowProfileLink) {
         $js .= "window.location = cbUserURLs[index];";
     }
     $js .= "return false;" . "}" . "});";
     $_CB_framework->outputCbJQuery($js);
     // Search JS:
     $isSearching = $search !== null;
     if ($isSearching && $params->get('list_search_collapse', 0) && !in_array($searchmode, array(1, 2))) {
         $isCollapsed = true;
     } else {
         $isCollapsed = false;
     }
     if (count($searchableFields) > 0) {
         cbUsersList::outputAdvancedSearchJs($isCollapsed ? null : $search);
     }
     // Base form URL:
     $baseUrl = $_CB_framework->rawViewUrl('userslist', true, array('listid' => (int) $row->listid, 'searchmode' => 0), 'html', 0, '&listid=' . (int) $row->listid);
     // Searching attributes:
     $showAll = $search === null;
     $criteriaTitle = cbReplaceVars(CBTxt::Th('UE_SEARCH_CRITERIA', 'Search criteria'), $myUser);
     if ($searchmode == 0 || $searchmode == 1 && count(get_object_vars($searchValues)) || $searchmode == 2) {
         $resultsTitle = cbReplaceVars(CBTxt::Th('UE_SEARCH_RESULTS', 'Search results'), $myUser);
     } else {
         $resultsTitle = null;
     }
     // Search content:
     $searchTabContent = $tabs->getSearchableContents($searchableFields, $myUser, $searchValues, $params->get('list_compare_types', 0));
     if (count($pluginAdditions['search'])) {
         $searchTabContent .= '<div class="cbUserListSearchPlugins">' . '<div>' . implode('</div><div>', $pluginAdditions['search']) . '</div>' . '</div>';
     }
     // User row content:
     $tableContent =& HTML_comprofiler::_getListTableContent($users, $columns, $fields);
     if ($params->get('list_grid_layout', 0)) {
         $layout = 'grid';
     } else {
         $layout = 'list';
     }
     $gridHeight = (int) $params->get('list_grid_height', 200);
     $gridWidth = (int) $params->get('list_grid_width', 200);
     if ($params->get('list_show_selector', 1)) {
         $listSelector = true;
     } else {
         $listSelector = false;
     }
     $pageClass = $_CB_framework->getMenuPageClass();
     $return = '<div class="cbUsersList cb_template cb_template_' . selectTemplate('dir') . ($pageClass ? ' ' . htmlspecialchars($pageClass) : null) . '">' . '<form action="' . $_CB_framework->rawViewUrl('userslist', true, array('listid' => (int) $row->listid), 'html', 0, '&listid=' . (int) $row->listid) . '" method="get" id="adminForm" name="adminForm" class="cb_form form-auto cbValidation">' . '<input type="hidden" name="option" value="com_comprofiler" />' . '<input type="hidden" name="view" value="userslist" />' . (!$listSelector ? '<input type="hidden" name="listid" value="' . (int) $row->listid . '" />' : null) . '<input type="hidden" name="Itemid" value="' . (int) $Itemid . '" />' . '<input type="hidden" name="limitstart" value="0" />' . '<input type="hidden" name="searchmode" value="' . (int) $searchmode . '" />' . '<input type="hidden" name="search" value="" />' . ($random ? '<input type="hidden" name="rand" value="' . (int) $random . '" />' : null) . cbGetSpoofInputTag('userslist') . $_PLUGINS->callTemplate($cbTemplate, 'List', 'drawListHead', array(&$input, $row->listid, $pageNav->total, $showAll, $searchTabContent, $isSearching, $baseUrl, $listTitleHtml, $listDescription, $criteriaTitle, $resultsTitle, $listAll, $listSelector, $isCollapsed, $searchmode), 'html');
     if ($searchmode == 0 || $searchmode == 1 && count(get_object_vars($searchValues)) || $searchmode == 2) {
         $canPage = $params->get('list_paging', 1) && ($pageNav->limitstart != 0 || $pageNav->limit <= $pageNav->total);
         if (count($pluginAdditions['header'])) {
             $return .= '<div class="cbUserListHeader">' . '<div>' . implode('</div><div>', $pluginAdditions['header']) . '</div>' . '</div>';
         }
         $return .= $_PLUGINS->callTemplate($cbTemplate, 'List', 'drawListBody', array(&$users, &$columns, &$tableContent, $row->listid, $allowProfileLink, $layout, $gridHeight, $gridWidth, $searchmode), 'html');
         if ($canPage) {
             $return .= '<div class="cbUserListPagination cbUserListPaginationBottom text-center">' . $pageNav->getListLinks() . '</div>';
         }
         if (count($pluginAdditions['footer'])) {
             $return .= '<div class="cbUserListFooter">' . '<div>' . implode('</div><div>', $pluginAdditions['footer']) . '</div>' . '</div>';
         }
     }
     $return .= '</form>' . '</div>' . cbPoweredBy();
     echo $return;
     $_CB_framework->setMenuMeta();
 }
Ejemplo n.º 26
0
 /**
  * returns HTML code for the filters
  *
  * @param  SimpleXMLElement[]  $items           The xml items to parse output
  * @param  string              $type            The type of xml items (e.g. filter, batch, import, export...)
  * @param  RegistryEditView    $editRowView     The edit view for the row
  * @param  string              $htmlFormatting  The HTML formatting for the filters ( 'table', 'td', 'none' )
  * @return array
  */
 function xmlItems($items, $type, $editRowView, $htmlFormatting = 'none')
 {
     $lists = array();
     if (count($items) > 0) {
         $valueObj = new Registry();
         $saveName = array();
         foreach ($items as $k => $v) {
             $valname = $type . '_' . $v['name'];
             $valueObj->set($valname, $v['value']);
             /** @var $v SimpleXMLElement[] */
             $saveName[$k] = $v['xml']->attributes('name');
             /** @noinspection PhpUndefinedMethodInspection */
             $items[$k]['xml']->addAttribute('name', $type . '_' . $saveName[$k]);
             /** @var $v array */
             $editRowView->setSelectValues($v['xml'], $v['selectValues']);
         }
         $renderedViews = array();
         foreach ($items as $k => $v) {
             /** @var $v SimpleXMLElement[] */
             $viewName = $v['xml']->attributes('view');
             if ($viewName) {
                 /** @noinspection PhpUndefinedMethodInspection */
                 $view = $items[$k]['xmlparent']->getChildByNameAttr('view', 'name', $viewName);
                 if (!$view) {
                     echo 'filter view ' . $viewName . ' not defined in filters';
                 }
             } else {
                 /** @noinspection PhpUndefinedMethodInspection */
                 $view = $items[$k]['xml']->getElementByPath('view');
             }
             $value = $items[$k]['value'];
             if ($value !== null && $value !== '') {
                 /** @noinspection PhpUndefinedMethodInspection */
                 $classes = $items[$k]['xml']->attributes('cssclass');
                 /** @noinspection PhpUndefinedMethodInspection */
                 $items[$k]['xml']->addAttribute('cssclass', $classes . ' focus');
             }
             if ($view) {
                 if (!$viewName || !in_array($viewName, $renderedViews)) {
                     /** @var SimpleXMLElement $view */
                     $htmlFormattingView = $view->attributes('viewformatting');
                     if ($htmlFormattingView == '') {
                         $htmlFormattingView = $htmlFormatting;
                     }
                     $lists[$k] = '<div class="cb' . htmlspecialchars(ucfirst($type)) . ' cb' . htmlspecialchars(ucfirst($type)) . 'View">' . $editRowView->renderEditRowView($view, $valueObj, $this, $this->_options, 'param', $htmlFormattingView) . '</div>';
                 }
                 if ($viewName) {
                     $renderedViews[] = $viewName;
                 }
             } else {
                 $editRowView->pushModelOfData($valueObj);
                 $editRowView->extendParamAttributes($items[$k]['xml'], $this->control_name());
                 $result = $editRowView->renderParam($items[$k]['xml'], $this->control_name(), false);
                 $editRowView->popModelOfData();
                 if ($result[0] || $result[1] || $result[2]) {
                     $lists[$k] = '<div class="cb' . htmlspecialchars(ucfirst($type)) . '">' . ($result[0] ? '<span class="cbLabelSpan">' . $result[0] . '</span> ' : null) . '<span class="cbFieldSpan">' . $result[1] . '</span>' . ($result[2] ? ' <span class="cbDescrSpan">' . $result[2] . '</span>' : null) . '</div>';
                 }
             }
         }
         foreach ($items as $k => $v) {
             /** @noinspection PhpUndefinedMethodInspection */
             $items[$k]['xml']->addAttribute('name', $saveName[$k]);
         }
     }
     return $lists;
 }
	/**
	 * @param Table $trigger
	 * @param Registry $params
	 */
	public static function usergroup( &$trigger, &$params )
	{
		$usergroupCount						=	substr_count( $trigger->get( 'params' ), 'usergroup_mode' );

		if ( $usergroupCount ) {
			$newParams						=	array();
			$newParams['usergroup']			=	array();

			$paramsMap						=	array(	'usergroup_mode' => 'mode', 'usergroup_parent' => 'parent', 'usergroup_title' => 'title',
														'usergroup_add' => 'add', 'usergroup_groups' => 'groups'
													);

			for ( $i = 0, $n = $usergroupCount; $i < $n; $i++ ) {
				if ( $i == 0 ) {
					$i						=	null;
				}

				$usergroup					=	array();

				foreach ( $paramsMap as $old => $new ) {
					$usergroup[$new]		=	$trigger->get( 'params' )->get( $old . $i, null, GetterInterface::RAW );
				}

				$newParams['usergroup'][]	=	$usergroup;
			}

			$params->load( $newParams );
		}
	}
 /**
  * Sends a PM notification
  *
  * @param cbmypmsproTable $pm
  * @param null|string     $message
  */
 private function sendNotification($pm, $message = null)
 {
     if (!$pm->get('id')) {
         return;
     }
     $itemId = uddeIMgetItemid($this->uddeIMConfigRAW);
     if (!uddeIMexistsEMN($pm->get('toid'))) {
         uddeIMinsertEMNdefaults($pm->get('toid'), $this->uddeIMConfigRAW);
     }
     $emailNotify = $this->uddeIMConfig->get('allowemailnotify', 0);
     $isModerated = uddeIMgetEMNmoderated($pm->get('fromid'));
     $isReply = stristr($pm->get('message'), $this->uddeIMConfig->get('quotedivider'), '__________');
     $isOnline = uddeIMisOnline($pm->get('toid'));
     // Strip the html and bbcode as uddeim supports neither in its notification:
     $message = strip_tags(uddeIMbbcode_strip($message ? $message : $pm->get('message'), $this->uddeIMConfigRAW));
     if (!$isModerated) {
         if ($emailNotify == 1 || $emailNotify == 2 && Application::User($pm->get('toid'))->isSuperAdmin()) {
             $status = uddeIMgetEMNstatus($pm->get('toid'));
             if ($status == 1 || $status == 2 && !$isOnline || $status == 10 && !$isReply || $status == 20 && !$isOnline && !$isReply) {
                 uddeIMdispatchEMN($pm->get('id'), $itemId, 0, $pm->get('fromid'), $pm->get('toid'), $message, 0, $this->uddeIMConfigRAW);
             }
         }
     }
 }
Ejemplo n.º 29
0
 /**
  * loads a plugins params into memory
  *
  * @param null|int              $pluginId
  * @param null|Registry|string  $extraParams
  */
 public function _loadParams($pluginId, $extraParams = null)
 {
     if ($pluginId === null) {
         $pluginId = $this->getPluginId();
     } else {
         $pluginId = (int) $pluginId;
     }
     $plugin = $this->getPluginObject($pluginId);
     if ($plugin === null) {
         return;
     }
     $paramsBase = $this->_getPluginParamsFromTable($plugin);
     if ($extraParams) {
         if (!$extraParams instanceof Registry) {
             /** @noinspection PhpDeprecationInspection */
             if ($extraParams instanceof cbParamsBase) {
                 /** @noinspection PhpDeprecationInspection */
                 $extraParams = new Registry($extraParams->toParamsArray());
             } else {
                 $extraParams = new Registry($extraParams);
             }
         }
         $extraArray = $extraParams->asArray();
         foreach ($extraArray as $k => $v) {
             $paramsBase->set($k, $v);
         }
     }
     $this->params = $paramsBase;
 }
Ejemplo n.º 30
-1
 /**
  * Draws Users list (ECHO)
  *
  * @param  int      $userId
  * @param  int      $listId
  * @param  array    $postData
  * @return void
  */
 public function drawUsersList($userId, $listId, $postData)
 {
     global $_CB_database, $_PLUGINS;
     $_PLUGINS->loadPluginGroup('user');
     $searchData = cbGetParam($postData, 'search');
     $limitstart = (int) cbGetParam($postData, 'limitstart');
     $searchMode = (int) cbGetParam($postData, 'searchmode', 0);
     $random = (int) cbGetParam($postData, 'rand', 0);
     $cbUser = CBuser::getInstance((int) $userId, false);
     $user = $cbUser->getUserData();
     $search = null;
     $input = array();
     $publishedLists = array();
     $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote('#__comprofiler_lists') . "\n WHERE " . $_CB_database->NameQuote('published') . " = 1" . "\n AND " . $_CB_database->NameQuote('viewaccesslevel') . " IN " . $_CB_database->safeArrayOfIntegers(Application::MyUser()->getAuthorisedViewLevels()) . "\n ORDER BY " . $_CB_database->NameQuote('ordering');
     $_CB_database->setQuery($query);
     /** @var ListTable[] $userLists */
     $userLists = $_CB_database->loadObjectList(null, '\\CB\\Database\\Table\\ListTable', array($_CB_database));
     if ($userLists) {
         foreach ($userLists as $userList) {
             $publishedLists[] = moscomprofilerHTML::makeOption((int) $userList->listid, strip_tags($cbUser->replaceUserVars($userList->title, false, false)));
             if (!$listId && $userList->default) {
                 $listId = (int) $userList->listid;
             }
         }
         if (!$listId) {
             $listId = (int) $userLists[0]->listid;
         }
     }
     if (!$listId) {
         echo CBTxt::Th('UE_NOLISTFOUND', 'There are no published user lists!');
         return;
     }
     if ($userLists) {
         $input['plists'] = moscomprofilerHTML::selectList($publishedLists, 'listid', 'class="form-control input-block" onchange="this.form.submit();"', 'value', 'text', (int) $listId, 1);
     }
     $row = self::getInstance((int) $listId);
     if (!$row) {
         echo CBTxt::Th('UE_LIST_DOES_NOT_EXIST', 'This list does not exist');
         return;
     }
     if (!$cbUser->authoriseView('userslist', $row->listid)) {
         echo CBTxt::Th('UE_NOT_AUTHORIZED', 'You are not authorized to view this page!');
         return;
     }
     $params = new Registry($row->params);
     if ($params->get('hotlink_protection', 0) == 1) {
         if ($searchData !== null || $limitstart) {
             cbSpoofCheck('userslist', 'GET');
         }
     }
     $limit = (int) $params->get('list_limit', 30);
     if (!$limit) {
         $limit = 30;
     }
     if ($params->get('list_paging', 1) != 1) {
         $limitstart = 0;
     }
     $isModerator = Application::MyUser()->isGlobalModerator();
     $_PLUGINS->trigger('onStartUsersList', array(&$listId, &$row, &$search, &$limitstart, &$limit));
     // Prepare query variables:
     $userGroupIds = explode('|*|', $row->usergroupids);
     $orderBy = self::getSorting($listId, $userId, $random);
     $filterBy = self::getFiltering($listId, $userId);
     $columns = self::getColumns($listId, $userId);
     // Grab all the fields the $user can access:
     $tabs = new cbTabs(0, 1);
     $fields = $tabs->_getTabFieldsDb(null, $user, 'list');
     // Build the field SQL:
     $tableReferences = array('#__comprofiler' => 'ue', '#__users' => 'u');
     $searchableFields = array();
     $fieldsSQL = cbUsersList::getFieldsSQL($columns, $fields, $tableReferences, $searchableFields, $params);
     $_PLUGINS->trigger('onAfterUsersListFieldsSql', array(&$columns, &$fields, &$tableReferences));
     // Build the internal joins and where statements best off list parameters:
     $tablesSQL = array();
     $joinsSQL = array();
     $tablesWhereSQL = array();
     if ($isModerator) {
         if (!$params->get('list_show_blocked', 0)) {
             $tablesWhereSQL['block'] = 'u.block = 0';
         }
         if (!$params->get('list_show_banned', 1)) {
             $tablesWhereSQL['banned'] = 'ue.banned = 0';
         }
         if (!$params->get('list_show_unapproved', 0)) {
             $tablesWhereSQL['approved'] = 'ue.approved = 1';
         }
         if (!$params->get('list_show_unconfirmed', 0)) {
             $tablesWhereSQL['confirmed'] = 'ue.confirmed = 1';
         }
     } else {
         $tablesWhereSQL = array('block' => 'u.block = 0', 'approved' => 'ue.approved = 1', 'confirmed' => 'ue.confirmed = 1', 'banned' => 'ue.banned = 0');
     }
     $joinsSQL[] = 'JOIN #__user_usergroup_map g ON g.`user_id` = u.`id`';
     if ($userGroupIds) {
         $tablesWhereSQL['gid'] = 'g.group_id IN ' . $_CB_database->safeArrayOfIntegers($userGroupIds);
     }
     foreach ($tableReferences as $table => $name) {
         if ($name == 'u') {
             $tablesSQL[] = $table . ' ' . $name;
         } else {
             $joinsSQL[] = 'JOIN ' . $table . ' ' . $name . ' ON ' . $name . '.`id` = u.`id`';
         }
     }
     // Build the search criteria:
     $searchValues = new stdClass();
     $searchesFromFields = $tabs->applySearchableContents($searchableFields, $searchValues, $postData, $params->get('list_compare_types', 0));
     $whereFields = $searchesFromFields->reduceSqlFormula($tableReferences, $joinsSQL, true);
     if ($whereFields) {
         $tablesWhereSQL[] = '(' . $whereFields . ')';
     }
     $_PLUGINS->trigger('onBeforeUsersListBuildQuery', array(&$tablesSQL, &$joinsSQL, &$tablesWhereSQL));
     // Construct the FROM and WHERE for the userlist query:
     $queryFrom = "FROM " . implode(', ', $tablesSQL) . (count($joinsSQL) ? "\n " . implode("\n ", $joinsSQL) : '') . "\n WHERE " . implode("\n AND ", $tablesWhereSQL) . " " . $filterBy;
     $_PLUGINS->trigger('onBeforeUsersListQuery', array(&$queryFrom, 1, $listId));
     // $ui = 1 (frontend)
     $errorMsg = null;
     // Checks if the list is being actively searched and it allows searching; otherwise reset back to normal:
     $searchCount = count(get_object_vars($searchValues));
     if ($params->get('list_search', 1) > 0 && $params->get('list_search_empty', 0) && !$searchCount) {
         $searchMode = 1;
         $listAll = false;
     } else {
         $listAll = $searchCount ? true : false;
     }
     if ($searchMode == 0 || $searchMode == 1 && $searchCount || $searchMode == 2) {
         // Prepare the userlist count query for pagination:
         $_CB_database->setQuery("SELECT COUNT( DISTINCT u.id ) " . $queryFrom);
         $total = $_CB_database->loadResult();
         if ($limit > $total || $limitstart >= $total) {
             $limitstart = 0;
         }
         // Prepare the actual userlist query to build a list of users:
         $query = "SELECT DISTINCT ue.*, u.*, '' AS 'NA' " . ($fieldsSQL ? ", " . $fieldsSQL . " " : '') . $queryFrom . " " . $orderBy;
         $_CB_database->setQuery($query, (int) $limitstart, (int) $limit);
         /** @var UserTable[] $users */
         $users = $_CB_database->loadObjectList(null, '\\CB\\Database\\Table\\UserTable', array($_CB_database));
         if (!$_CB_database->getErrorNum()) {
             $profileLink = $params->get('allow_profilelink', 1);
             // If users exist lets cache them and disable profile linking if necessary:
             if ($users) {
                 foreach (array_keys($users) as $k) {
                     // Add this user to cache:
                     CBuser::setUserGetCBUserInstance($users[$k]);
                     if (!$profileLink) {
                         $users[$k]->set('_allowProfileLink', 0);
                     }
                 }
             }
         } else {
             $errorMsg = CBTxt::T('UE_ERROR_IN_QUERY_TURN_SITE_DEBUG_ON_TO_VIEW', 'There is an error in the database query. Site admin can turn site debug to on to view and fix the query.');
         }
         if ($searchCount) {
             $search = '';
         } else {
             $search = null;
         }
         if ($search === null && ($searchMode == 1 && $searchCount || $searchMode == 2)) {
             $search = '';
         }
     } else {
         $total = 0;
         $users = array();
         if ($search === null) {
             $search = '';
         }
     }
     $pageNav = new cbPageNav($total, $limitstart, $limit);
     HTML_comprofiler::usersList($row, $users, $columns, $fields, $input, $search, $searchMode, $pageNav, $user, $searchableFields, $searchValues, $tabs, $errorMsg, $listAll, $random);
 }