We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42215
    • 17 Posts
    Hi!

    I would like to know if there is a way to make reports under Reports -> Manager Actions more detailed. For example, the line

    Mon Feb 17, 2014 10:42 PM | admin | user_group_update | Administrator (1)

    Doesn't say, what exactly has been changed. Of course it can often be found it out by comparing the records (user profiles, etc.) to what they looked like before. But not always. Plus, some changes may be temporal, and there are ocasions when site owner needs to know who exactly did what change.

    Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That's all that it is designed to display. It's a matter of data in, data out and there isn't any more data going in.

      The manager_actions table has six fields: id (auto-increment internal ID), user, occurred (datetime field), action (corresponds to the System Event that was triggered), classKey (of the object operated on) and item (the specific item operated on).

      So if you want a more detailed report, you would need to create your own plugin to act on every System Event of interest, and a CMP for displaying the report.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        The existing manager log is implemented by this function around line 1880 (Revo 2.3.1) of the core/model/modx/modx.class.php file:
            /**
             * Logs a manager action.
             *
             * @param string $action The action to pull from the lexicon module.
             * @param string $class_key The class key that the action is being performed on.
             * @param mixed $item The primary key id or array of keys to grab the object with.
             * @return modManagerLog The newly created modManagerLog object.
             */
            public function logManagerAction($action, $class_key, $item) {
                $userId = 0;
                if ($this->user instanceof modUser) {
                    $userId = $this->user->get('id');
                }
                $ml = $this->newObject('modManagerLog');
                $ml->set('user', (integer) $userId);
                $ml->set('occurred', strftime('%Y-%m-%d %H:%M:%S'));
                $ml->set('action', empty($action) ? 'unknown' : $action);
                $ml->set('classKey', empty($class_key) ? '' : $class_key);
                $ml->set('item', empty($item) ? 'unknown' : $item);
        
                if (!$ml->save()) {
                    $this->log(modX::LOG_LEVEL_ERROR, $this->lexicon('manager_log_err_save'));
                    return null;
                }
                return $ml;
            }
        


        And this is the schema of the manager_log table:
            <object class="modManagerLog" table="manager_log" extends="xPDOSimpleObject">
                <field key="user" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
                <field key="occurred" dbtype="datetime" phptype="datetime" null="true" default="0000-00-00 00:00:00" />
                <field key="action" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
                <field key="classKey" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
                <field key="item" dbtype="varchar" precision="255" phptype="string" null="false" default="0" />
        
                <aggregate alias="User" class="modUser" local="user" foreign="id" owner="foreign" cardinality="one" />
            </object>
        


        You can find the calls to the logManagerAction function in the core/model/modx/modprocessor.class.php with its various abstract processor classes. For example, in the process function of the abstract class modObjectCreateProcessor on line 659 you will see
                $this->fireAfterSaveEvent();
                $this->logManagerAction();
                return $this->cleanup();
        


        This means that every MODX object will automatically have a row inserted into the manager_log table after the new object has been saved. [ed. note: sottwell last edited this post 11 years, 11 months ago.]
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 42215
          • 17 Posts
          Ms. Ottwell, thanks for such a detailed view on the question!

          I hoped there is something to be done via System or other settrings. Unfortunately, right now I can't hack into a (my =) ) working project, will try it in future.