Esempio n. 1
0
 /**
  * Asserts on entries in an archive
  *
  * @param   lang.archive.Archive a
  * @param   array<string, string> entries
  * @throws  unittest.AssertionFailedError
  */
 protected function assertEntries(Archive $a, array $entries)
 {
     $a->open(ARCHIVE_READ);
     $actual = array();
     while ($key = $a->getEntry()) {
         $actual[$key] = $a->extract($key);
     }
     $this->assertEquals($entries, $actual);
     $a->close();
 }
Esempio n. 2
0
 /**
  * Return the text of this user's plan.
  * @param ts Timestamp of the requested plan
  * @public
  * @returns Plan
  */
 function getPlan(&$user, $ts = null)
 {
     if (!isset($ts)) {
         if ($user->getUserID() != $this->userID) {
             $this->addView();
             Archive::addView($this->userID, $this->lastUpdate);
             /* check for mutual snitch registration */
             if ($user->getSnitch() && $this->snitch) {
                 $this->addSnitchView($user);
             }
         }
         if (!isset($this->plan)) {
             $query = "SELECT content FROM plans WHERE uid=" . $this->userID;
             /* execute the query */
             $result = $this->dbh->query($query);
             if (isset($result) && !DB::isError($result)) {
                 $row = $result->fetchRow();
                 $this->plan = $row['content'];
             } else {
                 return PLANWORLD_ERROR;
             }
         }
         return $this->plan;
     } else {
         /* fetch it from the archives */
         if (Archive::isPublic($this->userID, $ts) || $user->getUserID() == $this->userID) {
             if ($user->getUserID() != $this->userID) {
                 Archive::addView($this->userID, $ts);
             }
             return Archive::getEntry($this->userID, $ts);
         } else {
             return "<strong>Error:</strong> You are not authorized to view this entry.";
         }
     }
 }
Esempio n. 3
0
 /**
  * Fetches this user's plan.
  * @public
  * @param user Requesting user (object)
  * @param date Date (for archived entries)
  * @returns string
  */
 function getPlan(&$user, $ts = null)
 {
     if (!isset($ts)) {
         if ($this->nodeinfo['Version'] < 2) {
             $val = $this->_call('plan.getText', array($this->localname, $user->getUsername() . '@' . PW_NAME, $user->getSnitch()));
         } else {
             $val = $this->_call('planworld.user.getPlan', array($this->localname, $user->getUsername() . '@' . PW_NAME, $user->getSnitch()));
         }
         return $val->scalar;
     } else {
         return Archive::getEntry($this->userID, $ts);
     }
     /*
     if (!is_array($val)) {
       print_r($val);
       return $val;
     } else {
       // some sort of error
     }
     */
 }