View Single Post
  #129  
Old 03-30-2006, 10:36 PM
johnmont johnmont is offline
 
Join Date: Feb 2006
Location: Chicago
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Plugin 1:

This will delete users from the gallery table when you delete them from the VB Admin Panel.

1. new hook (Plugin System: Add New Plugin)
2. Hook Location: userdata_delete
3. Call it "Delete Gallery User' or something similar
4. The code:

Code:
require_once('/absolute/path/to/gallery2/embed.php');
$ret = GalleryEmbed::init();

if ($ret) {
//  echo $ret->getAsHtml();
}
$uid = $this->existing['userid'];

$ret2 = GalleryEmbed::deleteUser($uid);

if ($ret2) {
//  echo "ret2".$ret2->getAsHtml() ;
}
You can uncomment the echos to see what is happening if badness occurs. Now whenever you delete a user from VB, you'll delete that user from Gallery, as well as the entry in the gallery ExternalIdMap database table.





Plugin 2:

This plugin will:

a. Update a VB user's information in the gallery2 database when they modify their User CP.
b. If a user has not been created already in the gallery2 database, a new user will be created.
c. Also note the use of custom user fields in the code, to allow for full names in the gallery information area.

Installation is similar to my previous post:

1. new hook (Plugin System: Add New Plugin)
2. location: userdata_postsave
3. call it "Update Gallery User" or something
4. The code follows:

Code:
require_once('/absolute/path/to/gallery2/embed.php'');
$ret = GalleryEmbed::init();

if ($ret) {
//  echo $ret->getAsHtml();
}


// Set fullname based upon custom fields
$fullname=$this->existing['field13'] ." ". $this->existing['field14'];


// Set the array for updating
$args['fullname']     =  $fullname ; 
$args['username']    = $this->existing['username']; 
$args['hashedpassword'] =   $this->existing['password']; 
$args['hashmethod'] =    'md5'; 
$args['email']       =   $this->existing['email']; 
$args['language']   =   $this->existing['lang_code']; 
$args['creationtimestamp']   =   $this->existing['joindate'];
$args['groupid']       =   $this->existing['usergroupid']; 

// Get the userid
$uid = $this->existing['userid'];


$ret = GalleryEmbed::isExternalIdMapped($uid,$args);

//Now if no user exists, we'll create one
//If user exists, we'll update existing user

if ($ret && ($ret->getErrorCode() & ERROR_MISSING_OBJECT)) {

 $ret2 = GalleryEmbed::createUser($uid,$args);

}else {

 $ret2 = GalleryEmbed::updateUser($uid,$args);

}


if ($ret2) {

//  echo "ret2: ". $ret2->getAsHtml() ;
}
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01261 seconds
  • Memory Usage 1,770KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete