示例#1
0
文件: User.php 项目: jlodom/planworld
 /**
  * Return formatted plan contents for display.
  * @param user User viewing plan.
  * @param plan Plan to display (if previewing).
  * @public
  * @returns Plan
  */
 function displayPlan(&$user, $plan = null, $ts = null)
 {
     $out = '<!-- ' . $this->getUserID() . '-->';
     if (!$user->planwatch->inPlanwatch($this) && !isset($plan)) {
         $out .= "<tt><a href=\"" . PW_URL_BASE . "add.php?add=" . $this->username . ";trans=t\" title=\"Add " . $this->username . " to my planwatch\">(Add to my planwatch)</a></tt><br />\n";
     } else {
         if (!isset($plan)) {
             $out .= "<tt><a href=\"" . PW_URL_BASE . "add.php?add=" . $this->username . ";trans=t;remove=t\" title=\"Remove " . $this->username . " from my planwatch\">(Remove from my planwatch)</a></tt><br />\n";
         }
     }
     $out .= "<tt>Login name: <strong>{$this->username}</strong>";
     if ($this->isUser() && $this->isSharedFor($user)) {
         $out .= " (<a href=\"" . PW_URL_INDEX . "?id=edit_plan;u={$this->username}\">edit</a>)";
     }
     $out .= " (<a href=\"#\" onclick=\"return send('" . $this->username . "');\" title=\"send to " . $this->username . "\">send</a>)<br />\n";
     /* user doesn't exist */
     if (!$this->isUser() || $this->lastLogin == 0 && $this->lastUpdate == 0) {
         $out .= "Last login: ???<br />\n";
         $out .= "Last update: ???<br />\n";
         $out .= "Plan:<br />\n";
         $out .= "[Sorry, could not find \"{$this->username}\"]</tt>\n";
         return $out;
     } else {
         if ($this->lastUpdate == 0) {
             $out .= "Last login: "******"<br />\n";
             $out .= "Last update: Never<br />\n";
             $out .= "Plan:<br />\n";
             $out .= "[No Plan]</tt>\n";
             return $out;
         }
     }
     $out .= "Last login: "******"<br />\n";
     $out .= "Last updated: " . Planworld::getDisplayDate($this->lastUpdate);
     if (Archive::hasPublicEntries($this->userID) || $user->getUserID() == $this->userID) {
         $out .= " (<a href=\"" . PW_URL_INDEX . "?id=archiving;u=" . $this->username . "\" title=\"Archives\">archives</a>)";
     }
     $out .= "<br />\n";
     if (isset($ts)) {
         $out .= "Date posted: " . Planworld::getDisplayDate($ts);
         if ($name = Archive::getName($this->userID, $ts)) {
             $out .= ' (<strong>' . Archive::getName($this->userID, $ts) . '</strong>)';
         }
         $out .= "<br />\n";
     }
     $out .= "Plan:</tt>\n";
     /* assemble text of plan */
     if (!isset($plan)) {
         $plan_txt = $this->getPlan($user, $ts);
     } else {
         // plan was passed as a parameter (probably previewing)
         $plan_txt = $plan;
     }
     /* only wordwrap if a text plan */
     if (preg_match('/^\\<pre\\>(.*)\\<\\/pre\\>\\s*$/misD', $plan_txt)) {
         $out .= Planworld::addLinks(wordwrap($plan_txt, 76, "\n", 1), $user->getUsername());
     } else {
         $out .= Planworld::addLinks($plan_txt, $user->getUsername());
     }
     return $out;
 }
示例#2
0
 /**
  * Return formatted plan contents for display.
  * @param user User viewing plan.
  * @public
  * @returns Plan
  */
 function displayPlan(&$user, $plan = null, $ts = null)
 {
     $plan_txt = $this->getPlan($user, $ts);
     $out = '';
     if (!$user->planwatch->inPlanwatch($this)) {
         $out .= "<tt><a href=\"" . PW_URL_BASE . "add.php?add=" . $this->username . ";trans=t\" title=\"Add " . $this->username . " to my planwatch\">(Add to my planwatch)</a></tt><br />\n";
     } else {
         $out .= "<tt><a href=\"" . PW_URL_BASE . "add.php?add=" . $this->username . ";trans=t;remove=t\" title=\"Remove " . $this->username . " from my planwatch\">(Remove from my planwatch)</a></tt><br />\n";
     }
     $out .= "<tt>Login name: {$this->username}";
     /* user doesn't exist */
     if (!$this->isUser() || $this->lastLogin == 0 && $this->lastUpdate == 0) {
         $out .= "<br />\n";
         $out .= "Last login: ???<br />\n";
         $out .= "Last update: ???<br />\n";
         $out .= "Plan:<br />\n";
         $out .= "[Sorry, could not find \"{$this->username}\"]</tt>\n";
     } else {
         if ($this->lastUpdate == 0) {
             $out .= " (<a href=\"#\" onclick=\"return send('" . $this->username . "');\" title=\"send to " . $this->username . "\">send</a>)<br />\n";
         } else {
             $out .= " (<a href=\"#\" onclick=\"return send('" . $this->username . "');\" title=\"send to " . $this->username . "\">send</a>)<br />\n";
             $out .= "Last login: "******"<br />\n";
             $out .= "Last updated: " . Planworld::getDisplayDate($this->lastUpdate) . "<br />\n";
             if (isset($ts)) {
                 $out .= "Date posted: " . Planworld::getDisplayDate($ts) . "<br />\n";
             }
             $out .= "Plan:</tt>\n";
             if (empty($plan_txt)) {
                 $plan_txt = "<tt><br />\n[No plan]</tt>";
             }
             /* only wordwrap if a text plan */
             if (Planworld::isText($plan_txt)) {
                 $out .= Planworld::addLinks(wordwrap($plan_txt, 76, "\n", 1), $user->getUsername(), $this->host);
             } else {
                 $out .= Planworld::addLinks($plan_txt, $user->getUsername(), $this->host);
             }
         }
     }
     return $out;
 }