21
maxxy
User Profile Visitor ?
  • 2010/2/10 1:27

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


i would like to integrate the yogurt module profile visitor by the late suico in user profile module

i know i can use alfred module yogurt+profile..ive tested it and ive reason not to use it at the moment ..

a. there is bug that had not yet been fixed in the module..
b. same folder name with core profile module
c. i don't really need all the other extra feature
i know i can disable the feature such as friends, audio, album, wall etc

all i want now is a profile visitor and profile module thats all..

and i decided to stick with the stable profile module from the core

i made some search in the yogurt module to look for references to visitors....

anyone can help me to integrate this to profile module ?

in index.php

$xoopsTpl->assign('lang_visitors',_MD_YOGURT_VISITORS);




$controler->visitors_factory->purgeVisits();
/**

 * Visitors 

 */  



if ($controler->isAnonym==0){

    

    
/**

     * Fectching last visitors

     */

    
if ($controler->uidOwner != $xoopsUser->getVar('uid')){

        
$visitor_now $controler->visitors_factory->create();

        
$visitor_now->setVar('uid_owner'$controler->uidOwner);

        
$visitor_now->setVar('uid_visitor',$xoopsUser->getVar('uid'));

        
$visitor_now->setVar('uname_visitor',$xoopsUser->getVar('uname'));

        
$controler->visitors_factory->insert($visitor_now);

    }

    
$criteria_visitors = new criteria('uid_owner',  $controler->uidOwner);

    
//$criteria_visitors->setLimit(5);

    
$visitors_object_array $controler->visitors_factory->getObjects($criteria_visitors);



    
/**

     * Lets populate an array with the dati from visitors

     */  

    
$i 0;

    foreach (
$visitors_object_array as $visitor){

        

        

        
$indice                         $visitor->getVar("uid_visitor","s");

        
$visitors_array[$indice]        = $visitor->getVar("uname_visitor","s");

        

        

    
$i++;

    }

    

    
$xoopsTpl->assign('visitors'$visitors_array);

    
$xoopsTpl->assign('lang_visitors',_MD_YOGURT_VISITORS);




language/main.php definitions
define("_MD_YOGURT_VISITORS","Visitors who visited your profile recently");



SQL file

CREATE TABLE `yogurt_visitors` (

  `
cod_visitint(11NOT NULL auto_increment,

  `
uid_ownerint(11NOT NULL,

  `
uid_visitorint(11NOT NULL,

  `
uname_visitorvarchar(30NOT NULL,

`
datetimetimestamp NOT NULL default CURRENT_TIMESTAMP,

  
PRIMARY KEY  (`cod_visit`)

TYPE=MyISAM;




class/yogurt_visitors.php

// yogurt_visitors.php,v 1

//  ---------------------------------------------------------------- //

// Author: Bruno Barthez                                               //

// ----------------------------------------------------------------- //



include_once XOOPS_ROOT_PATH."/class/xoopsobject.php";

/**

* yogurt_visitors class.  

* $this class is responsible for providing data access mechanisms to the data source 

* of XOOPS user class objects.

*/





class yogurt_visitors extends XoopsObject



    var 
$db;



// constructor

    
function yogurt_visitors ($id=null)

    {

        
$this->db =& Database::getInstance();

        
$this->initVar("cod_visit",XOBJ_DTYPE_INT,null,false,10);

        
$this->initVar("uid_owner",XOBJ_DTYPE_INT,null,false,10);

        
$this->initVar("uid_visitor",XOBJ_DTYPE_INT,null,false,10);

        
$this->initVar("uname_visitor",XOBJ_DTYPE_TXTBOXnullfalse);

        if ( !empty(
$id) ) {

            if ( 
is_array($id) ) {

                
$this->assignVars($id);

            } else {

                    
$this->load(intval($id));

            }

        } else {

            
$this->setNew();

        }

        

    }



    function 
load($id)

    {

        
$sql 'SELECT * FROM '.$this->db->prefix("yogurt_visitors").' WHERE cod_visit='.$id;

        
$myrow $this->db->fetchArray($this->db->query($sql));

        
$this->assignVars($myrow);

        if (!
$myrow) {

            
$this->setNew();

        }

    }



    function 
getAllyogurt_visitorss($criteria=array(), $asobject=false$sort="cod_visit"$order="ASC"$limit=0$start=0)

    {

        
$db =& Database::getInstance();

        
$ret = array();

        
$where_query "";

        if ( 
is_array($criteria) && count($criteria) > ) {

            
$where_query " WHERE";

            foreach ( 
$criteria as $c ) {

                
$where_query .= $c AND";

            }

            
$where_query substr($where_query0, -4);

        } elseif ( !
is_array($criteria) && $criteria) {

            
$where_query " WHERE ".$criteria;

        }

        if ( !
$asobject ) {

            
$sql "SELECT cod_visit FROM ".$db->prefix("yogurt_visitors")."$where_query ORDER BY $sort $order";

            
$result $db->query($sql,$limit,$start);

            while ( 
$myrow $db->fetchArray($result) ) {

                
$ret[] = $myrow['yogurt_visitors_id'];

            }

        } else {

            
$sql "SELECT * FROM ".$db->prefix("yogurt_visitors")."$where_query ORDER BY $sort $order";

            
$result $db->query($sql,$limit,$start);

            while ( 
$myrow $db->fetchArray($result) ) {

                
$ret[] = new yogurt_visitors ($myrow);

            }

        }

        return 
$ret;

    }

}

// -------------------------------------------------------------------------

// ------------------yogurt_visitors user handler class -------------------

// -------------------------------------------------------------------------

/**

* yogurt_visitorshandler class.  

* This class provides simple mecanisme for yogurt_visitors object

*/



class Xoopsyogurt_visitorsHandler extends XoopsObjectHandler

{



    
/**

    * create a new yogurt_visitors

    * 

    * @param bool $isNew flag the new objects as "new"?

    * @return object yogurt_visitors

    */

    
function &create($isNew true)    {

        
$yogurt_visitors = new yogurt_visitors();

        if (
$isNew) {

            
$yogurt_visitors->setNew();

        }

        else{

        
$yogurt_visitors->unsetNew();

        }



        

        return 
$yogurt_visitors;

    }



    
/**

    * retrieve a yogurt_visitors

    * 

    * @param int $id of the yogurt_visitors

    * @return mixed reference to the {@link yogurt_visitors} object, FALSE if failed

    */

    
function &get($id)    {

            
$sql 'SELECT * FROM '.$this->db->prefix('yogurt_visitors').' WHERE cod_visit='.$id;

            if (!
$result $this->db->query($sql)) {

                return 
false;

            }

            
$numrows $this->db->getRowsNum($result);

            if (
$numrows == 1) {

                
$yogurt_visitors = new yogurt_visitors();

                
$yogurt_visitors->assignVars($this->db->fetchArray($result));

                return 
$yogurt_visitors;

            }

                return 
false;

    }



/**

* insert a new yogurt_visitors in the database



* @param object $yogurt_visitors reference to the {@link yogurt_visitors} object

* @param bool $force

* @return bool FALSE if failed, TRUE if already present and unchanged or successful

*/

    
function insert(&$yogurt_visitors$force false) {

        Global 
$xoopsConfig;

        if (
get_class($yogurt_visitors) != 'yogurt_visitors') {

                return 
false;

        }

        if (!
$yogurt_visitors->isDirty()) {

                return 
true;

        }

        if (!
$yogurt_visitors->cleanVars()) {

                return 
false;

        }

        foreach (
$yogurt_visitors->cleanVars as $k => $v) {

                ${
$k} = $v;

        }

        
$now "date_add(now(), interval ".$xoopsConfig['server_TZ']." hour)";

        if (
$yogurt_visitors->isNew()) {

            
// ajout/modification d'un yogurt_visitors

            
$yogurt_visitors = new yogurt_visitors();

            
$format "INSERT INTO %s (cod_visit, uid_owner, uid_visitor,uname_visitor)";

            
$format .= "VALUES (%u, %u, %u, %s)";

            
$sql sprintf($format 

            
$this->db->prefix('yogurt_visitors'), 

            
$cod_visit

            
,$uid_owner

            
,$uid_visitor

            
,$this->db->quoteString($uname_visitor)

            );

            
$force true;

        } else {

            
$format "UPDATE %s SET ";

            
$format .="cod_visit=%u, uid_owner=%u, uid_visitor=%u, uname_visitor=%s ";

            
$format .=" WHERE cod_visit = %u";

            
$sql sprintf($format$this->db->prefix('yogurt_visitors'),

            
$cod_visit

            
,$uid_owner

            
,$uid_visitor

            
,$this->db->quoteString($uname_visitor)

            , 
$cod_visit);

        }

        if (
false != $force) {

            
$result $this->db->queryF($sql);

        } else {

            
$result $this->db->query($sql);

        }

        if (!
$result) {

            return 
false;

        }

        if (empty(
$cod_visit)) {

            
$cod_visit $this->db->getInsertId();

        }

        
$yogurt_visitors->assignVar('cod_visit'$cod_visit);

        return 
true;

    }



    
/**

     * delete a yogurt_visitors from the database

     * 

     * @param object $yogurt_visitors reference to the yogurt_visitors to delete

     * @param bool $force

     * @return bool FALSE if failed.

     */

    
function delete(&$yogurt_visitors$force false)

    {

        if (
get_class($yogurt_visitors) != 'yogurt_visitors') {

            return 
false;

        }

        
$sql sprintf("DELETE FROM %s WHERE cod_visit = %u"$this->db->prefix("yogurt_visitors"), $yogurt_visitors->getVar('cod_visit'));

        if (
false != $force) {

            
$result $this->db->queryF($sql);

        } else {

            
$result $this->db->query($sql);

        }

        if (!
$result) {

            return 
false;

        }

        return 
true;

    }



    
/**

    * retrieve yogurt_visitorss from the database

    * 

    * @param object $criteria {@link CriteriaElement} conditions to be met

    * @param bool $id_as_key use the UID as key for the array?

    * @return array array of {@link yogurt_visitors} objects

    */

    
function &getObjects($criteria null$id_as_key false)

    {

        
$ret = array();

        
$limit $start 0;

        
$sql 'SELECT * FROM '.$this->db->prefix('yogurt_visitors');

        if (isset(
$criteria) && is_subclass_of($criteria'criteriaelement')) {

            
$sql .= ' '.$criteria->renderWhere();

        if (
$criteria->getSort() != '') {

            
$sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();

        }

        
$limit $criteria->getLimit();

        
$start $criteria->getStart();

        }

        
$result $this->db->query($sql$limit$start);

        if (!
$result) {

            return 
$ret;

        }

        while (
$myrow $this->db->fetchArray($result)) {

            
$yogurt_visitors = new yogurt_visitors();

            
$yogurt_visitors->assignVars($myrow);

            if (!
$id_as_key) {

                
$ret[] =& $yogurt_visitors;

            } else {

                
$ret[$myrow['cod_visit']] =& $yogurt_visitors;

            }

            unset(
$yogurt_visitors);

        }

        return 
$ret;

    }



    
/**

    * count yogurt_visitorss matching a condition

    * 

    * @param object $criteria {@link CriteriaElement} to match

    * @return int count of yogurt_visitorss

    */

    
function getCount($criteria null)

    {

        
$sql 'SELECT COUNT(*) FROM '.$this->db->prefix('yogurt_visitors');

        if (isset(
$criteria) && is_subclass_of($criteria'criteriaelement')) {

            
$sql .= ' '.$criteria->renderWhere();

        }

        
$result $this->db->query($sql);

        if (!
$result) {

            return 
0;

        }

        list(
$count) = $this->db->fetchRow($result);

        return 
$count;

    } 



    
/**

    * delete yogurt_visitorss matching a set of conditions

    * 

    * @param object $criteria {@link CriteriaElement} 

    * @return bool FALSE if deletion failed

    */

    
function deleteAll($criteria null$force=false)

    {

        
$sql 'DELETE FROM '.$this->db->prefix('yogurt_visitors');

        if (isset(
$criteria) && is_subclass_of($criteria'criteriaelement')) {

            
$sql .= ' '.$criteria->renderWhere();

        }

        if (
false != $force) {

            if (!
$result $this->db->queryF($sql)) {

            return 
false;

        };

        } else {

            if (!
$result $this->db->query($sql)) {

            return 
false;

        }

        }

        

        return 
true;

    }

    

    function 
purgeVisits(){

        

        
$sql 'DELETE FROM '.$this->db->prefix('yogurt_visitors').' WHERE (datetime<(DATE_SUB(NOW(), INTERVAL 7 DAY))) ';



            if (!
$result $this->db->queryF($sql)) {

            return 
false;

        }

        

        

        return 
true;

        

    }

}





?>






template/yogurt_index.html

<{ if ($isOwner==1) }>



    <
div id="yogurt-album-visitors" class="outer">

        <
h2 class="head"><{$lang_visitors}>h2>

        <
p>

        <{foreach 
from=$visitors key=k item=v}>

             <
a href=index.php?uid=<{$k}> > <{$v}> a>&nbsp

        <{/foreach}> 

        p>

        div>

<{ /if }>





in

class yogurt_controller;

include_once("class/yogurt_visitors.php");
        function 
createFactories()

    {

 

$this->visitors_factory         = new Xoopsyogurt_visitorsHandler($this->db);
}



and maybe there is other..but that s what i've found so far



Help !



22
maxxy
comment Bug ?
  • 2010/1/11 14:40

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


i just noticed this

pick any article in news - xoops.org

see the comments

every comment have posted and updated time

is thats how its are ? why have both ?

is this a bug ?



23
maxxy
Re: XOOPS 2.5 Pre-Alpha
  • 2010/1/11 14:15

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


if you look and read at the wishlist here...

Wishlist For XOOPS Future
https://xoops.org/modules/mediawiki/index.php/Wishlist_for_Next_XOOPS

most of it has been fulfille....Thank you xoops


hopefully.....more request is granted




24
maxxy
seconds, minutes, days ago, Today
  • 2010/1/11 14:10

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


is there any quick hack to change the user last login in user info

to use advance timing ?

eg 1 seconds/minutes/days ago or today

right now display as

2010/1/11 22:09



25
maxxy
Re: Profile Module - Field weight: > 9 incorrect display
  • 2010/1/11 14:02

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


tested in XOOPS 2.4.3 ...

it works

Thank you trabis



26
maxxy
Re: Profile Module - Field weight: > 9 incorrect display
  • 2010/1/5 10:11

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


bump



27
maxxy
Re: Download module with the ability to allow free as well as paid downloads
  • 2010/1/5 10:09

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


no payment just an idea

create 2 group in admin - normal user and premium user

allow only premium user to download...in download module permission




28
maxxy
Re: Profile Module - Field weight: > 9 incorrect display
  • 2009/12/31 17:13

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


can someone report this bug to svn ?



29
maxxy
Re: Profile Module - Website Row is displayed even value is empty
  • 2009/12/30 14:49

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


Thank you..yes it works


hope this change can be commit to svn

can the mode help to change the title to Fixed




30
maxxy
Re: Profile Module - Website Row is displayed even value is empty
  • 2009/12/30 4:40

  • maxxy

  • Quite a regular

  • Posts: 286

  • Since: 2007/6/11


anyone ?

had this same problem last without the profile module

https://xoops.org/modules/newbb/viewtopic.php?topic_id=59901&forum=5&post_id=276823#forumpost276823


Fixed by dugris in 2.018.1
http://xoops.svn.sourceforge.net/viewvc/xoops?view=rev&revision=1246


not sure if this really has been fixed ?


right now using profile module




TopTop
« 1 2 (3) 4 5 6 ... 22 »



Login

Who's Online

214 user(s) are online (147 user(s) are browsing Support Forums)


Members: 0


Guests: 214


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jun 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits