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_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_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(); }
function plug_cbgroupjivephoto_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( 'photo_captcha' ) ) || ( $pluginParams->get( 'photo_captcha' ) == null ) ) { return; } // Migrate photo integration parameters: $photo = new PluginTable(); $photo->load( array( 'element' => 'cbgroupjivephoto' ) ); $photoParams = new Registry( $photo->get( 'params' ) ); if ( $photoParams->get( 'migrated' ) ) { return; } $photoParams->set( 'groups_photo_captcha', $pluginParams->get( 'photo_captcha' ) ); $photoParams->set( 'groups_photo_image_height', $pluginParams->get( 'photo_maxheight' ) ); $photoParams->set( 'groups_photo_image_width', $pluginParams->get( 'photo_maxwidth' ) ); $photoParams->set( 'groups_photo_thumbnail_height', $pluginParams->get( 'photo_thumbheight' ) ); $photoParams->set( 'groups_photo_thumbnail_width', $pluginParams->get( 'photo_thumbwidth' ) ); $photoParams->set( 'groups_photo_max_size', $pluginParams->get( 'photo_maxsize' ) ); $photoParams->set( 'groups_photo_paging', $pluginParams->get( 'photo_paging' ) ); $photoParams->set( 'groups_photo_limit', $pluginParams->get( 'photo_limit' ) ); $photoParams->set( 'groups_photo_search', $pluginParams->get( 'photo_search' ) ); $photoParams->set( 'migrated', true ); $photo->set( 'params', $photoParams->asJson() ); $photo->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(); }
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_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' ); } }
/** * 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; }