ScooterDonpon

Members
  • Content count

    5
  • Joined

  • Last visited


About ScooterDonpon

  • Rank
    IPB Newbie
  • Birthday October 06

Profile Information

  • Gender Male

ScooterDonpon's Activity

  1. ScooterDonpon added a post in a topic: (M34) Videos System   

    I have created a hook to show how many videos a member has added to show in userpane info in topic view. But i'm having trouble with it not incrementing when a video is posted. This is what i currently have videosPosted.xml
  2. ScooterDonpon added a post in a topic: Help with hook   

    ok thanks.
  3. ScooterDonpon added a post in a topic: Help with hook   

    Here is all of the code I have videosPosted.xml
  4. ScooterDonpon added a post in a topic: Help with hook   

    I have created a hook to show how many videos a member has added to show in userpane info in topic view. But i'm having trouble with it not updating.


    <hook_file_real>videosPostedQuery.php</hook_file_real>
    <hook_type>dataHooks</hook_type>
    <hook_classname>videosPostedQuery</hook_classname>
    <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:14:"topicViewQuery";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:0:"";s:9:"skinGroup";N;s:12:"skinFunction";N;s:4:"type";N;s:2:"id";N;s:8:"position";N;}]]></hook_data>
    <hooks_source><![CDATA[<?php
    class videosPostedQuery
    {
    public function handleData( $data )
    {
    /* Add additional fields to be queried */
    $data['members'] = array_merge( $data['members'], array( 'videos_posted' ) );

    /* Return */
    return $data;
    }
    }]]></hooks_source>
    </file>
    <file>
    <hook_file_real>videosPostedIncrement.php</hook_file_real>
    <hook_type>dataHooks</hook_type>
    <hook_classname>videosPostedIncrement</hook_classname>
    <hook_data><![CDATA[a:8:{s:12:"dataLocation";s:12:"postAddTopic";s:14:"libApplication";s:0:"";s:15:"classToOverload";s:0:"";s:9:"skinGroup";N;s:12:"skinFunction";N;s:4:"type";N;s:2:"id";N;s:8:"position";N;}]]></hook_data>
    <hooks_source><![CDATA[<?php
    class videosPostedIncrement
    {
    protected $registry;
    protected $DB;

    public function __construct()
    {
    /* Make registry objects */
    $this->registry = ipsRegistry::instance();
    $this->DB = $this->registry->DB();
    }

    public function handleData( $data )
    {
    /* Got an ID? */
    if ( $data['author_id'] )
    {
    /* Update their count */
    $this->DB->update( 'members', "videos_posted=videos_posted+1", 'member_id=' . $data['author_id'] , false, true );
    }

    /* Return */
    return $data;
    }
    }]]></hooks_source>
    </file>
    </hookfiles>
    <hookextras_custom>
    <file>
    <filename>videosPostedCustom.php</filename>
    <source><![CDATA[<?php
    class videosPostedCustom
    {
    protected $registry;
    protected $DB;

    public function __construct( ipsRegistry $registry )
    {
    /* Make registry objects */
    $this->registry = $registry;
    $this->DB = $this->registry->DB();
    }

    public function install()
    {
    /* INIT */
    $counts = array();

    /* Query for all counts of videos posted */
    $this->DB->build( array( 'select' => 'author_id, COUNT(*) AS cnt', 'from' => 'videos', 'group' => 'author_id' ) );
    $this->DB->execute();

    /* Loop... */
    while ( $row = $this->DB->fetch() )
    {
    if ( $row['author_id'] && $row['cnt'] )
    {
    $counts[ $row['cnt'] ][] = $row['author_id'];
    }
    }

    /* Now update each member */
    if ( count( $counts ) )
    {
    foreach ( $counts as $cnt => $ids )
    {
    if ( count( $ids ) )
    {
    $this->DB->update( 'members', array( 'videos_posted' => $cnt ), 'member_id IN (' . implode( ',', $ids ) . ')' );
    }
    }
    }

About Me

Status Feed