We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    Just sitting down to plan a new component to a site in development & looking at the requirements for the user profiles.... they are, 'extensive'. I was wondering if there were already tools/extras &/or advice on where to get started with this.

    Basically this is going to be a 'community' site of sorts, where Canadian artists can register an account, go through the approval email/process then edit their [modx] default profiles. An administrator is notified of the registration & can approve or reject them as an artist [by moving them to a different user group]

    This all works fine out of the box, the next step is the tricky part. [and barely started]

    Once a user is promoted to an artist, they will have the ability to add extended user profile data that will be publicly searchable, some of the more notable types of information are:
    - Artist Bio
    - genre[s] [an array]
    - band members [array]
    - discography [array]
    - gig list [array]
    - MP3s [files]
    - video[s] [youtube link]
    - tech requirements [zip file]
    - high res photos [zip file]
    - press releases [zip file]

    I can't put all that into the extended user fields & still be able to search on it reliably/efficiently so I'm going the route of adding some custom tables VIA CMPGenerator [which was surprisingly easy!]

    So here is my incomplete and somewhat fuzzy plan:
    - Use CMPGenerator & PackMan to create all the extra tables & packup the code etc when done.
    - Use FormIt for the users to edit the extended profiles [mostly for the ability to use validation, pre & post hooks]
    - Use AdvancedSearch to search & display data from the new tables [spoke to the developer already - this should work]

    which still leaves a few holes in my plan:

    1. I would like to be able to have users upload their media files to an amazon bucket ~ no idea how to implement that.
    2. How to link all this into modUser so that user management in the manager still works correctly [i.e. deleting a user removes all the extra data, banning or disabling a user makes all the extra data 'no longer available']
    3. Moving array data into individual tables [i.e. genre] for ease of searching. Thoughts? comments?

    I'm sure I can a lot of this with little extra Formit pre & post hooks, but the big questions are, how to upload to Amazon & will I have the ability to easily package this [in the event a reinstall is needed on a modx upgrade/update]


    Thoughts? comments? advice?

    -thanks
    -sean
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 26503
      • 620 Posts
      Started working away on this & trying to understand the extending modUser docs [and the CMPgenerator docs] so far I have this:

      <?xml version="1.0" encoding="UTF-8"?>
      <model package="extArtist" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
      
      	<!-- the main artist extra data table, inherit & extend modUser -->
      	<object class="Artistdata" table="artistdata" extends="modUser">
      		<field key="internalkey" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="" />
      		<field key="banner" dbtype="varchar" precision="255" phptype="string" null="true" />
      		<field key="bio" dbtype="longtext" phptype="string" null="true" />
      		<field key="mname" dbtype="text" phptype="string" null="true" />
      		<field key="mphone" dbtype="text" phptype="string" null="true" />
      		<field key="memail" dbtype="text" phptype="string" null="true" />
      		<field key="website" dbtype="text" phptype="string" null="true" />
      		<field key="facebook" dbtype="text" phptype="string" null="true" />
      		<field key="youtube" dbtype="text" phptype="string" null="true" />
      		<field key="twitter" dbtype="text" phptype="string" null="true" />
      		<composite alias="agenremap" local="internalkey" foreign="uid" cardinality="many" owner="local" />
      	</object>
      
      	<!-- map user ids to multiple genre names -->
      	<object class="Agenremap" table="agenremap" extends="xPDOSimpleObject">
      		<field key="uid" dbtype="int" precision="10" phptype="integer" null="false" default="" />
      		<field key="gid" dbtype="int" precision="10" phptype="integer" null="false" default="" />
      	</object>
      	
      	<!-- a simple list of genres [indie, jazz, blues etc] -->
      	<object class="Agenres" table="agenres" extends="xPDOSimpleObject">
      		<field key="genre" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
      	</object>
      	
      	<!-- map user ids to the location and type of media they own -->
      	<object class="Amedia" table="amedia" extends="xPDOSimpleObject">
      		<field key="uid" dbtype="int" precision="10" phptype="integer" null="false" default="" />
      		<field key="type" dbtype="int" precision="10" phptype="integer" null="false" default="" />
      		<field key="location" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
      	</object>
      	
      	<!-- a simple list of media types [images, zips, video etc] -->
      	<object class="Amediatypes" table="amediatypes" extends="xPDOSimpleObject">
      		<field key="value" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
      	</object>
      	
      </model>
      


      Wondering if I am on the right path here?
        *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

        Sean Kimball CLP, CLS.
        Technical Director / Sr. Developer | BigBlock Studios
        ._______________________________________________.
        Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
        27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
        phone/fax: 905-426-5525
        • 18373 ☆ A M B ☆
        • 3,141 Posts
        You may have luck diving into the S3 media source driver for your amazon requirements.

        For the packaging you'll need a build script (unless PackMan would be sufficient).. I think there's a specific tutorial for that in the docs?
          Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

          Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • 26503
          • 620 Posts
          Thanks Mark;

          made some progress on this yesterday, have not even touched the file upload issue - but will look into it.

          -sean
            *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

            Sean Kimball CLP, CLS.
            Technical Director / Sr. Developer | BigBlock Studios
            ._______________________________________________.
            Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
            27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
            phone/fax: 905-426-5525
            • 26503
            • 620 Posts
            So I started at square one here trying to understand what it happening, I can't get the http://rtfm.modx.com/display/revolution20/Extending+modUser example to work at all.. getting frustrated.

            I cut and pasted the schema, generated the model I was able to add data to the table, count rows etc. Satisfied it was working I edited the extuser.class.php in /core/components/extendeduser/model/extendeduser/ and added:
            <?php
            /**
             * @package extendeduser
             * @subpackage user.mysql
             */
            class extUser extends modUser {
                function __construct(xPDO & $xpdo) {
                    parent :: __construct($xpdo);
                    $this->set('class_key','extUser');
                }
            }
            ?>
            

            Then I added the extension_packages system setting ~ [{"extendeduser":{"path":"[[++core_path]]components/extendeduser/model/"}}]
            Then I created the /core/components/extendeduser/extendeduser.class.php (cut and pasted from article)

            Then I added this into a snippet and called it:
            <?php
            $x = $modx->getService('extendeduser','Sampleclass',$modx->getOption('core_path',null, MODX_CORE_PATH).'components/extendeduser/',$scriptProperties);
            if (!($x instanceof Extendeduser)) {
                $modx->log(modX::LOG_LEVEL_ERROR,'[Extendeduser] Could not load Extendeduser class.');
                $modx->event->output(true);
            }
            return;
            


            No matter what I do I get an error:
            Fatal error: Call to undefined method stdClass::output() in /var/www/vhosts/domain.com/httpdocs/core/cache/includes/elements/modsnippet/27.include.cache.php on line 10
            


            looking back in extendeduser.class.php there is the line:
            $this->modx->addPackage('extendeduser', $this->extPath .'model/', 'ut_');
            

            Which after reading the addPackage docs seems to indicate it should be:
            $this->modx->addPackage('extendeduser', $this->extPath .'model/extendeduser/');
            


            Either way I still get the error... I can even put absolute paths in there and still get the error ex: /vhome/domain.com/httpdocs/core/components/extendeduser/model/extendeduser/

            Does the example posted actually work? What's wrong here??
              *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

              Sean Kimball CLP, CLS.
              Technical Director / Sr. Developer | BigBlock Studios
              ._______________________________________________.
              Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
              27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
              phone/fax: 905-426-5525
              • 18373 ☆ A M B ☆
              • 3,141 Posts
              The snippet you posted looks like it needs to be a plugin to me? That is to assume thd snippet you posted is ID 27, which is where the error comes from.
                Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                • 26503
                • 620 Posts
                Hum.

                Threw this into a plugin,

                <?php
                $x = $modx->getService('extendeduser','Sampleclass',$modx->getOption('core_path',null, MODX_CORE_PATH).'components/extendeduser/',$scriptProperties);
                if (!($x instanceof Extendeduser)) {
                    $modx->log(modX::LOG_LEVEL_ERROR,'[Extendeduser] Could not load Extendeduser class.');
                    $modx->event->output(true);
                }
                return;
                


                running on manager & weblogin events. after a manager login I get the error log:

                
                 [2012-04-09 20:59:14] (ERROR @ /manager/index.php) Could not load class: Sampleclass from sampleclass.
                [2012-04-09 20:59:14] (ERROR @ /manager/index.php) Problem getting service extendeduser, instance of class Sampleclass, from path /var/www/vhosts/domain.com/httpdocs/core/components/extendeduser/
                [2012-04-09 20:59:14] (ERROR @ /manager/index.php) [Extendeduser] Could not load Extendeduser class.
                
                


                the file: /var/www/vhosts/domain.com/httpdocs/core/components/extendeduser/extendeduser.class.php is there .....

                argh.
                  *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                  Sean Kimball CLP, CLS.
                  Technical Director / Sr. Developer | BigBlock Studios
                  ._______________________________________________.
                  Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                  27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                  phone/fax: 905-426-5525
                  • 18373 ☆ A M B ☆
                  • 3,141 Posts
                  $modx->getService('extendeduser','Sampleclass',...)

                  should probably be..
                  $modx->getService('extendeduser','extUser',...)
                    Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                    Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                    • 26503
                    • 620 Posts
                    the classfile in the example is:

                    if (!class_exists('Sampleclass')) {
                        class Sampleclass
                        {
                            function __construct(modX & $modx, array $config= array ()) {
                     
                                /* Import modx as a reference */
                                $this->modx= & $modx;
                     
                                /* Establish the environment */
                                $this->extPath= $modx->getOption('core_path',null, MODX_CORE_PATH).'components/extendeduser/';
                                $this->modx->addPackage('extendeduser', $this->extPath .'model/', 'ut_');
                                $this->_config= array_merge(array (
                                    'userID' => $this->modx->user->get('id'),
                                ), $config);
                     
                                /* Define the user */
                                $this->userObj = $this->setUser($this->_config['userID']);
                                $this->userID = $this->userObj->get('id');
                            }
                     
                            function __destruct() {
                                unset ($this->extPath, $this->userObj, $this->userID, $this->_config);
                            }
                     
                            /**
                             * Returns object of type Phone.
                             */
                            public function getPhoneObj() {
                                $this->userObj->getOne('Phones');
                                return $this->userObj->Phones;
                            }
                     
                            /**
                             * Returns object utUser instance of modUser Defaults to current user.
                             * @param $userID
                             */
                            public function getUserObj($userID) {
                                return $this->modx->getObject('modUser', $userID);
                            }
                     
                            /**
                             * Establishes the user.
                             * @param int $userID
                             */
                            public function setUser($userID){
                                return $this->getUserObj($userID);
                            }
                        }
                    }
                    


                    So if i am interpreting getService correctly [http://rtfm.modx.com/display/revolution20/modX.getService] that should be right?
                      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                      Sean Kimball CLP, CLS.
                      Technical Director / Sr. Developer | BigBlock Studios
                      ._______________________________________________.
                      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                      phone/fax: 905-426-5525
                      • 18373 ☆ A M B ☆
                      • 3,141 Posts
                      Ah, I assumed you were still working with what you posted before.

                      In that case the problem is probably the path:

                      $x = $modx->getService(..,..,$modx->getOption('core_path',null, MODX_CORE_PATH).'components/extendeduser/',$scriptProperties);

                      should probably be
                      $x = $modx->getService(..,..,$modx->getOption('core_path',null, MODX_CORE_PATH).'components/extendeduser/model/',$scriptProperties);
                        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.