Table of Contents

NP_AutoJoin.php

Description: this plugin allows registered members to join specified teams by filling a form.

General Plugin info
Author: Rodrigo Moraes
Current Version: 1.0
Download: -
Code: code
Demo: -
Forum Thread: forum thread

Code

Copy the following code and save it as NP_AutoJoin.php:

<?
class NP_AutoJoin extends NucleusPlugin {
function getName()  { return 'Auto Join'; }
function getAuthor()  { return 'Rodrigo Moraes'; }
function getURL() { return 'http://www.tipos.com.br'; }
function getVersion() { return '1.0'; }
function getDescription()
   { return 'Allow registered members to join specified teams by filling a form.'; }
function getMinNucleusVersion()  { return '200'; }
   function supportsFeature($what) {
      switch($what) {
	 case 'SqlTablePrefix':
	    return 1;
	 default:
	    return 0;
      }
   }
 
function doSkinVar($skinType) {
  global $BlogURL, $manager, $CONF, $blog, $member, $blogid, $blog_coletive, $blog_col;
 
  /* get current blog id */
  $blogid = $blog->getID();
 
  /* get current member id */
  $memberid = $member->getID();
 
  /* check if member belongs to the current team */
  $teammember = $member->isTeamMember($blogid);
//  echo $teammember;
 
  if ($memberid) {
 
   /* Replace XXX and/or YYY by the blog id(s) you want to be available. Use one line for each coletive open blog you have. Exclude the YYY line if you have just one coletive open blog. */
   $v = "";
   $blog_coletivo[XXX] = 1;  if ($v) { $v .= ","; } $v .= XXX;
   $blog_coletivo[YYY] = 1;  if ($v) { $v .= ","; } $v .= YYY;
 
   // Verify if a coletive blog exists
   if ($v) {
    $query = "SELECT tblog FROM ".sql_table('team')."
               WHERE tmember = ".$memberid." AND tblog IN (".$v.")";
    $rs = mysql_query($query);
   $ver_blog = "";
    while($row = mysql_fetch_object($rs)) {
     $tblog_s = $row->tblog;
     $ver_blog[$tblog_s] = 1;
     // echo "<br />blog_coletive[$blog_coletive] - tblog_s = ".$tblog_s;
    // metodo update para retirar o usuario do blog coletivo
     if ($blog_coletive == update) {
      if (!$blog_col[$tblog_s]) {
         $query = "DELETE FROM ".sql_table('team')." WHERE tblog = $tblog_s AND tmember = ".$memberid;
         $res=mysql_query($query);
         //echo "<br /> query_delete = $query";
         $ver_blog[$tblog_s] = "";
      }
     }
    }
   echo "
   <form method=\"get\" action=\"".$BlogURL."index.php\">
    <input type=\"Hidden\" name=\"blog_coletive\" value=\"update\">
   <br />Which coletive blog do you want to join?<br />";
 
    $query = "SELECT bnumber,bname FROM ".sql_table('blog')." WHERE bnumber IN ($v) ORDER BY bname";
    $rs = mysql_query($query);
    while($row = mysql_fetch_object($rs)) {
     $bnumber_s  = $row->bnumber;
     if ($blog_coletive == "update") {
      if ((!$ver_blog[$bnumber_s]) && ($blog_col[$bnumber_s])) {
         $query = "INSERT INTO ".sql_table('team')." (tmember,tblog,tadmin)
                                    VALUES ($memberid,$bnumber_s,0)";
         $res=mysql_query($query);
         //echo "<br /> query_insert = $query";
         $ver_blog[$bnumber_s] = 1;
      }
    }
     $bname_s = $row->bname;
    echo "<br /><input type=\"checkbox\" name=\"blog_col[".$bnumber_s."]\" value=\"".$bnumber_s."\" ";
    if ($ver_blog[$bnumber_s]) { echo "checked"; }
    echo "> $bname_s<br />";
    }
   echo "
   <input type=\"Submit\" name=\"\" value=\"join!\">
   </form>";
   }
  }
}
}
?>

Go to this forum thread for more info about this plugin.

Plugin review

Error messages after installation and poor documentation. 2007-10-29 kg

Back to the plugins overview

autojoin.txt · Last modified: 2007/10/29 23:42 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki