/** * creates folders progessively and corrects their permissions * * @param string $root * @param string $category * @param string $group */ static public function createFolderPath( $root = null, $category = null, $group = null ) { $plugin = cbgjClass::getPlugin(); $folderMode = cbgjClass::getFolderPerms(); $fileMode = cbgjClass::getFilePerms(); if ( $root && ( ! is_dir( $root ) ) ) { $oldmask = @umask( 0 ); if ( @mkdir( $root, $folderMode, true ) ) { @umask( $oldmask ); @chmod( $root, $folderMode ); if ( ! file_exists( $root . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $root . '/index.html' ); @chmod( $root . '/index.html', $fileMode ); } } else { @umask( $oldmask ); } } if ( $category && ( ! is_dir( $category ) ) ) { $oldmask = @umask( 0 ); if ( @mkdir( $category, $folderMode, true ) ) { @umask( $oldmask ); @chmod( $category, $folderMode ); if ( ! file_exists( $category . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $category . '/index.html' ); @chmod( $category . '/index.html', $fileMode ); } } else { @umask( $oldmask ); } } if ( $group && ( ! is_dir( $group ) ) ) { $oldmask = @umask( 0 ); if ( @mkdir( $group, $folderMode, true ) ) { @umask( $oldmask ); @chmod( $group, $folderMode ); if ( ! file_exists( $group . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $group . '/index.html' ); @chmod( $group . '/index.html', $fileMode ); } } else { @umask( $oldmask ); } } }
/** * migrate old groupjive data * * @param moscomprofilerUser $user * @param object $plugin */ private function showMigrate( $user, $plugin ) { global $_CB_framework, $_CB_database; $gj_categories = $_CB_database->getTableStatus( '#__gj_grcategory' ); $gj_groups = $_CB_database->getTableStatus( '#__gj_groups' ); $gj_users = $_CB_database->getTableStatus( '#__gj_users' ); $gj_path = $_CB_framework->getCfg( 'absolute_path' ) . '/images/com_groupjive'; if ( $gj_categories ) { $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__gj_grcategory' ); $_CB_database->setQuery( $query ); $categories = $_CB_database->loadObjectList(); if ( $categories ) foreach ( $categories as $category ) { $cat = new cbgjCategory( $_CB_database ); $types = array(); if ( $category->create_open ) { $types[] = 1; } if ( $category->create_closed ) { $types[] = 2; } if ( $category->create_invite ) { $types[] = 3; } $cat->set( 'user_id', (int) ( $category->admin ? $category->admin : $user->id ) ); $cat->set( 'name', trim( strip_tags( $category->catname ) ) ); if ( $plugin->params->get( 'category_editor', 1 ) >= 2 ) { $cat->set( 'description', cbgjClass::getFilteredText( $category->descr ) ); } else { $cat->set( 'description', trim( strip_tags( $category->descr ) ) ); } $cat->set( 'types', ( is_array( $types ) ? implode( '|*|', $types ) : null ) ); $cat->set( 'date', cbgjClass::getUTCDate() ); $cat->set( 'ordering', (int) $category->ordering ); $cat->set( 'published', (int) $category->published ); if ( $category->access == 2 ) { $cat->set( 'access', 30 ); } elseif ( $category->access == 1 ) { $cat->set( 'access', -1 ); } else { $cat->set( 'access', -2 ); } if ( ! $cat->store() ) { cbgjClass::getPluginURL( array( 'tools' ), CBTxt::P( 'Category failed to migrate! Error: [error]', array( '[error]' => $cat->getError() ) ), false, true, 'error' ); } $cat_path = $plugin->imgsAbs . '/' . (int) $cat->get( 'id' ); if ( $category->cat_image ) { $mode = cbgjClass::getFilePerms(); if ( ! is_dir( $cat_path ) ) { $oldmask = @umask( 0 ); if ( @mkdir( $cat_path, cbgjClass::getFolderPerms(), true ) ) { @umask( $oldmask ); if ( ! file_exists( $plugin->imgsAbs . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $plugin->imgsAbs . '/index.html' ); @chmod( $plugin->imgsAbs . '/index.html', $mode ); } if ( ! file_exists( $cat_path . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $cat_path . '/index.html' ); @chmod( $cat_path . '/index.html', $mode ); } } else { @umask( $oldmask ); } } if ( file_exists( $gj_path . '/' . $category->cat_image ) && ( ! file_exists( $cat_path . '/' . $category->cat_image ) ) ) { @copy( $gj_path . '/' . $category->cat_image, $cat_path . '/' . $category->cat_image ); @chmod( $cat_path . '/' . $category->cat_imag, $mode ); } if ( file_exists( $gj_path . '/tn' . $category->cat_image ) && ( ! file_exists( $cat_path . '/tn' . $category->cat_image ) ) ) { @copy( $gj_path . '/tn' . $category->cat_image, $cat_path . '/tn' . $category->cat_image ); @chmod( $cat_path . '/tn' . $category->cat_image, $mode ); } if ( file_exists( $cat_path . $category->cat_image ) && file_exists( $cat_path . 'tn' . $category->cat_image ) ) { $cat->set( 'logo', $category->cat_image ); } } if ( $gj_groups ) { $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__gj_groups' ) . "\n WHERE " . $_CB_database->NameQuote( 'category' ) . " = " . (int) $cat->get( 'id' ); $_CB_database->setQuery( $query ); $groups = $_CB_database->loadObjectList(); if ( $groups ) foreach ( $groups as $group ) { $grp = new cbgjGroup( $_CB_database ); $grp->set( 'user_id', (int) ( $group->user_id ? $group->user_id : $user->id ) ); $grp->set( 'name', trim( strip_tags( $group->name ) ) ); if ( $plugin->params->get( 'group_editor', 1 ) >= 2 ) { $grp->set( 'description', cbgjClass::getFilteredText( $group->descr ) ); } else { $grp->set( 'description', trim( strip_tags( $group->descr ) ) ); } $grp->set( 'type', (int) $group->type ); $grp->set( 'date', $group->date_s ); $grp->set( 'category', $cat->get( 'id' ) ); $grp->set( 'published', (int) $group->active ); $grp->set( 'access', -2 ); if ( ! $grp->store() ) { cbgjClass::getPluginURL( array( 'tools' ), CBTxt::P( 'Group failed to migrate! Error: [error]', array( '[error]' => $grp->getError() ) ), false, true, 'error' ); } $grp_path = $plugin->imgsAbs . '/' . (int) $cat->get( 'id' ) . '/' . (int) $grp->get( 'id' ); if ( $group->logo ) { $mode = cbgjClass::getFilePerms(); if ( ! is_dir( $grp_path ) ) { $oldmask = @umask( 0 ); if ( @mkdir( $grp_path, cbgjClass::getFolderPerms(), true ) ) { @umask( $oldmask ); if ( ! file_exists( $plugin->imgsAbs . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $plugin->imgsAbs . '/index.html' ); @chmod( $plugin->imgsAbs . '/index.html', $mode ); } if ( ! file_exists( $cat_path . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $cat_path . '/index.html' ); @chmod( $cat_path . '/index.html', $mode ); } if ( ! file_exists( $grp_path . '/index.html' ) ) { @copy( $plugin->absPath . '/images/index.html', $grp_path . '/index.html' ); @chmod( $grp_path . '/index.html', $mode ); } } else { @umask( $oldmask ); } } if ( file_exists( $gj_path . '/' . $group->logo ) && ( ! file_exists( $grp_path . '/' . $group->logo ) ) ) { @copy( $gj_path . '/' . $group->logo, $grp_path . '/' . $group->logo ); @chmod( $grp_path . '/' . $group->logo, $mode ); } if ( file_exists( $gj_path . '/tn' . $group->logo ) && ( ! file_exists( $grp_path . '/tn' . $group->logo ) ) ) { @copy( $gj_path . '/tn' . $group->logo, $grp_path . '/tn' . $group->logo ); @chmod( $grp_path . '/tn' . $group->logo, $mode ); } if ( file_exists( $grp_path . $group->logo ) && file_exists( $grp_path . 'tn' . $group->logo ) ) { $grp->set( 'logo', $group->logo ); } } $owner = new cbgjUser( $_CB_database ); $owner->set( 'user_id', (int) $grp->get( 'user_id' ) ); $owner->set( 'group', (int) $grp->get( 'id' ) ); $owner->set( 'date', $grp->get( 'date' ) ); $owner->set( 'status', 4 ); if ( ! $owner->store() ) { cbgjClass::getPluginURL( array( 'tools' ), CBTxt::P( 'Owner failed to migrate! Error: [error]', array( '[error]' => $owner->getError() ) ), false, true, 'error' ); } if ( $gj_users ) { $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__gj_users' ) . "\n WHERE " . $_CB_database->NameQuote( 'id_group' ) . " = " . (int) $grp->get( 'id' ) . "\n AND " . $_CB_database->NameQuote( 'id_user' ) . " != " . (int) $grp->get( 'user_id' ); $_CB_database->setQuery( $query ); $users = $_CB_database->loadObjectList(); if ( $users ) foreach ( $users as $u ) { $usr = new cbgjUser( $_CB_database ); $usr->set( 'user_id', (int) $u->id_user ); $usr->set( 'group', (int) $grp->get( 'id' ) ); $usr->set( 'date', $u->date ); $usr->set( 'status', ( $u->status == 'active' ? 1 : 0 ) ); if ( ! $usr->store() ) { cbgjClass::getPluginURL( array( 'tools' ), CBTxt::P( 'User failed to migrate! Error: [error]', array( '[error]' => $usr->getError() ) ), false, true, 'error' ); } } } } } } } else { cbgjClass::getPluginURL( array( 'tools' ), CBTxt::T( 'Nothing to migrate.' ), false, true, 'error' ); } cbgjClass::getPluginURL( array( 'tools' ), CBTxt::T( 'GroupJive migration successful.' ), false, true ); }