/**
  * Load the activity object.
  * @param String $itemid the id of the item whose activity was auditied.
  * @param String $userid the id of the user who caused the audit to happen. Who performed the activity.
  * @param String $type the type of audited item ('Vote', 'Node', 'Connection', 'Follow', 'View')
  * @param int $modificationdate the time of the audit in seconds from epoch
  * @param String $changetype the type of activity (view, edit, add, delete etc)
  * @param String $xml the xml for the audited history object
  * @param String $style (optional - default 'long') may be 'short' or 'long' or 'cif'
  */
 function load($itemid, $userid, $type, $modificationdate, $changetype, $xml, $style = 'long')
 {
     $this->itemid = $itemid;
     $this->userid = $userid;
     $this->type = $type;
     $this->modificationdate = $modificationdate;
     $this->changetype = $changetype;
     $this->xml = $xml;
     $this->user = new User($userid);
     if ($style != 'cif') {
         $this->user = $this->user->load($style);
     }
     switch ($this->type) {
         case "Node":
             if ($style == 'long') {
                 $this->node = getIdeaFromAuditXML($this->xml);
             }
             $this->currentnode = getNode($this->itemid, $style);
             if ($this->currentnode instanceof Error) {
                 if ($this->currentnode->code == 7007) {
                     // NODE NOT FOUND
                     $this->tombstone == true;
                 }
             }
             break;
         case "Connection":
             if ($style == 'long') {
                 $this->con = getConnectionFromAuditXML($this->xml);
             }
             $this->currentcon = getConnection($this->itemid, $style);
             if ($this->currentcon instanceof Error) {
                 if ($this->currentcon->code == 7008) {
                     // CONNECTION NODE FOUND
                     $this->tombstone == true;
                 }
             }
             break;
     }
     try {
         $this->canview($style);
     } catch (Exception $e) {
         $this->itemid = "";
         $this->userid = "";
         $this->type = "";
         $this->modificationdate = "";
         $this->changetype = "";
         $this->xml = "";
         $this->user = "";
         $this->node = "";
         $this->con = "";
         $this->currentnode = "";
         $this->currentcon = "";
         return access_denied_error();
     }
 }
 if ($activity->type == 'Node') {
     $node = getIdeaFromAuditXML($activity->xml);
     if ($node instanceof CNode && ($node->private == 'N' || $node->userid == $user->userid) && (in_array($node->role->name, $CFG->BASE_TYPES) || in_array($node->role->name, $CFG->EVIDENCE_TYPES))) {
         $nextMessage .= '<br /><br /><span style="font-style:italic">' . $LNG->ADMIN_CRON_FOLLOW_ON_THE . ' ' . date("d M Y - H:i", $activity->modificationdate) . ' </span>';
         $nextMessage .= ' ' . $activity->user->name . ' ';
         if ($activity->changetype == 'add') {
             $nextMessage .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_ADDED . '</span> ' . $LNG->ADMIN_CRON_FOLLOW_THIS_ITEM;
         } else {
             if ($activity->changetype == 'edit') {
                 $nextMessage .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_EDITED . '</span> ' . $LNG->ADMIN_CRON_FOLLOW_THIS_ITEM;
             }
         }
     }
 } else {
     if ($activity->type == 'Connection') {
         $con = getConnectionFromAuditXML($activity->xml);
         if ($con instanceof Connection && ($con->private == 'N' || $con->userid == $user->userid)) {
             if ((in_array($con->from->role->name, $CFG->BASE_TYPES) || in_array($con->from->role->name, $CFG->EVIDENCE_TYPES)) && (in_array($con->to->role->name, $CFG->BASE_TYPES) || in_array($con->to->role->name, $CFG->EVIDENCE_TYPES))) {
                 $otherend;
                 $othernode;
                 $otherrole;
                 if ($con->from->nodeid != $nodeid) {
                     $otherend = 'from';
                     $othernode = $con->from;
                     $otherrole = $con->fromrole;
                 } else {
                     if ($con->to->nodeid != $nodeid) {
                         $otherend = 'to';
                         $othernode = $con->to;
                         $otherrole = $con->torole;
                     }
示例#3
0
/**
 * Turn the given list of activities into a text report.
 */
function processActivityList($activities, $node, $user)
{
    global $CFG, $LNG;
    $report = "";
    $nodetypename = $node['NodeType'];
    $nodeid = $node['NodeID'];
    foreach ($activities as $activity) {
        //error_log($activity->type);
        if ($activity->type == 'Follow') {
            $report .= '<br /><br /><span style="font-style:italic">' . $LNG->ADMIN_CRON_FOLLOW_ON_THE . ' ' . date("d M Y - H:i", $activity->modificationdate) . ' </span>';
            $report .= ' ' . $activity->user->name . ' ';
            $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_STARTED . '</span> ' . $LNG->ADMIN_CRON_FOLLOW_THIS_ITEM;
        } else {
            if ($activity->type == 'Vote') {
                $report .= '<br /><br /><span style="font-style:italic">' . $LNG->ADMIN_CRON_FOLLOW_ON_THE . ' ' . date("d M Y - H:i", $activity->modificationdate) . ' </span>';
                $report .= ' ' . $activity->user->name . ' ';
                if ($activity->changetype == 'Y') {
                    $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_PROMOTED . '</span> ' . $LNG->ADMIN_CRON_FOLLOW_THIS_ITEM;
                } else {
                    if ($activity->changetype == 'N') {
                        $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_DEMOTED . '</span> ' . $LNG->ADMIN_CRON_FOLLOW_THIS_ITEM;
                    }
                }
            } else {
                if ($activity->type == 'Node') {
                    $node = getIdeaFromAuditXML($activity->xml);
                    if ($node instanceof CNode && ($node->private == 'N' || $node->userid == $user->userid) && (in_array($node->role->name, $CFG->BASE_TYPES) || in_array($node->role->name, $CFG->EVIDENCE_TYPES))) {
                        $report .= '<br /><br /><span style="font-style:italic">' . $LNG->ADMIN_CRON_FOLLOW_ON_THE . ' ' . date("d M Y - H:i", $activity->modificationdate) . ' </span>';
                        $report .= ' ' . $activity->user->name . ' ';
                        if ($activity->changetype == 'add') {
                            $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_ADDED . '</span> ' . $LNG->ADMIN_CRON_FOLLOW_THIS_ITEM;
                        } else {
                            if ($activity->changetype == 'edit') {
                                $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_EDITED . '</span> ' . $LNG->ADMIN_CRON_FOLLOW_THIS_ITEM;
                            }
                        }
                    }
                } else {
                    if ($activity->type == 'Connection') {
                        $con = getConnectionFromAuditXML($activity->xml);
                        if ($con instanceof Connection && isset($con->from) && isset($con->to) && ($con->from->private == 'N' && $con->to->private == 'N' || $con->from->userid == $user->userid && $con->to->userid == $user->userid)) {
                            if ($con->private == 'N' || $con->userid == $user->userid) {
                                if ((in_array($con->from->role->name, $CFG->BASE_TYPES) || in_array($con->from->role->name, $CFG->EVIDENCE_TYPES)) && (in_array($con->to->role->name, $CFG->BASE_TYPES) || in_array($con->to->role->name, $CFG->EVIDENCE_TYPES))) {
                                    $otherend;
                                    $othernode;
                                    $otherrole;
                                    if ($con->from->nodeid != $nodeid) {
                                        $otherend = 'from';
                                        $othernode = $con->from;
                                        $otherrole = $con->fromrole;
                                    } else {
                                        if ($con->to->nodeid != $nodeid) {
                                            $otherend = 'to';
                                            $othernode = $con->to;
                                            $otherrole = $con->torole;
                                        }
                                    }
                                    $report .= '<br /><br /><span style="font-style:italic">' . $LNG->ADMIN_CRON_FOLLOW_ON_THE . ' ' . date("d M Y - H:i", $activity->modificationdate) . ' </span>';
                                    $report .= ' ' . $activity->user->name . ' ';
                                    if ($activity->changetype == 'add') {
                                        if ($othernode->role->name == 'Comment') {
                                            $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_ADDED . ' ' . getNodeTypeText($othernode->role->name, false) . '</span>: "' . $othernode->name . '"';
                                        } else {
                                            if (in_array($othernode->role->name, $CFG->EVIDENCE_TYPES)) {
                                                if ($otherrole->name == 'Pro') {
                                                    $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_ADDED_SUPPORTING_EVIDENCE . '</span>: "' . $othernode->name . '"';
                                                } else {
                                                    if ($otherrole->name == 'Con') {
                                                        $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_ADDED_COUNTER_EVIDENCE . '</span>: "' . $othernode->name . '"';
                                                    } else {
                                                        $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_ASSOCIATED_EVIDENCE . '</span>: ' . $othernode->name . '"';
                                                    }
                                                }
                                            } else {
                                                $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_ASSOCIATED_WITH . ' ' . getNodeTypeText($othernode->role->name, false) . '</span>: "' . $othernode->name . '"';
                                            }
                                        }
                                    } else {
                                        if ($activity->changetype == 'delete') {
                                            if ($othernode->role->name == 'Comment') {
                                                $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_REMOVED . ' ' . getNodeTypeText($othernode->role->name, false) . '</span>: "' . $othernode->name . '"';
                                            } else {
                                                if (in_array($othernode->role->name, $CFG->EVIDENCE_TYPES)) {
                                                    if ($otherrole->name == 'Pro') {
                                                        $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_REMOVED_SUPPORTING_EVIDENCE . '</span>: "' . $othernode->name . '"';
                                                    } else {
                                                        if ($otherrole->name == 'Con') {
                                                            $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_REMOVED_COUNTER_EVIDENCE . '</span>: "' . $othernode->name . '"';
                                                        } else {
                                                            $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_REMOVED_EVIDENCE . '</span>: ' . $othernode->name . '"';
                                                        }
                                                    }
                                                } else {
                                                    $report .= '<span style="font-weight:bold">' . $LNG->ADMIN_CRON_FOLLOW_REMOVED_ASSOCIATION . ' ' . getNodeTypeText($othernode->role->name, false) . '</span>: "' . $othernode->name . '"';
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return $report;
}