示例#1
0
    function createVEvent($data)
    {
        $url = FoodleUtils::getUrl() . 'foodle/' . $data['foodle']['id'];
        $identifier = $data['foodle']['id'];
        if (!empty($data['subid'])) {
            $identifier .= '#' . $data['subid'];
        }
        $title = $data['foodle']['name'];
        $status = 'CONFIRMED';
        $transp = 'OPAQUE';
        if ($data['type'] === 'tentative') {
            $status = 'TENTATIVE';
            $transp = 'TRANSPARENT';
            $title .= ' (tentative)';
        }
        return 'BEGIN:VEVENT
CREATED:' . $data['dtend'] . '
UID:' . strtoupper(sha1($identifier)) . '@foodl.org
' . $data['dtstart'] . '
' . $data['dtend'] . '
STATUS: ' . $status . '
TRANSP: ' . $transp . '
SUMMARY:' . $title . '
DTSTAMP:' . $this->dtstamp() . '
DESCRIPTION:' . trim(chunk_split(preg_replace('/[\\n\\r]+/', '\\n\\n', strip_tags($data['foodle']['descr'])), 76, "\n ")) . '
URL;VALUE=URI:' . $url . '
SEQUENCE:' . $data['created'] . '
END:VEVENT
';
    }
示例#2
0
文件: CSVFoodle.php 项目: r4mp/Foodle
 function show()
 {
     $s = ';';
     $url = FoodleUtils::getUrl() . 'foodle/' . $this->foodle->identifier;
     $responses = $this->foodle->getResponses();
     session_cache_limiter('public');
     $extra = $this->foodle->getExtraFields();
     header("Content-type: text/csv; charset=utf-8");
     header("Content-disposition:  attachment; filename=foodle-" . $this->foodle->identifier . "_" . date("Y-m-d") . ".csv");
     foreach ($responses as $response) {
         $extrastr = '';
         $user = $this->fdb->readUser($response->userid);
         if (!empty($user) && !empty($extra)) {
             foreach ($extra as $e) {
                 switch ($e) {
                     case 'org':
                         $extrastr .= $user->org . $s;
                         break;
                     case 'location':
                         $extrastr .= $user->location . $s;
                         break;
                     case 'timezone':
                         $extrastr .= $user->timezone . $s;
                         break;
                     default:
                 }
             }
         }
         echo $response->username . $s . $response->userid . $s . $response->email . $s . $extrastr . join($s, $response->response['data']) . $s . date("Y-m-d H:i", $response->created) . "\r\n";
     }
 }
示例#3
0
    function getContent($type)
    {
        $t = new SimpleSAML_XHTML_Template($this->config, 'foodleresponse.php', 'foodle_foodle');
        if (empty($_REQUEST['skipintro'])) {
            $text = '<h2 class="foodleHeader">' . $this->foodle->name . '</h2>';
            $text .= '<div class="foodleDescription">' . $this->foodle->getDescription() . '</div>';
        }
        $table = XHTMLEmbed::getTable($t, $this->foodle);
        $text .= $table;
        $url = FoodleUtils::getUrl() . 'foodle/' . $this->foodle->identifier;
        $additionalData = '<div class="foodleAdditionalDetails"><form target="_blank" action="' . htmlspecialchars($url) . '"><input type="submit" name="subm" value="Go to this Foodle" /></form></div>';
        $text .= $additionalData;
        $content = array('name' => $this->foodle->name, 'descr' => $this->foodle->getDescription(), 'result' => $table, 'extra' => $additionalData);
        $iframe = '<!DOCTYPE html>
		<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
		<head>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

			<title>Foodle</title>
			<style type="text/css">
				body {
					font-family: Arial;					
				}
				table {
					border: 1px solid #ccc;
					border-collapse: collapse;
					margin: .5em 0px;
				}
				table tr td {
					padding: 3px 5px;
					border: 1px solid #ccc;
				}
			</style>

		</head>

		<body>
			
			' . $text . '
		
		</body>
		</html>
		';
        switch ($type) {
            case 'htmliframe':
                header('Content-Type: text/html; charset=utf8');
                echo $iframe;
                break;
            case 'htmlembed':
                header('Content-Type: text/html; charset=utf8');
                echo $text;
                break;
            case 'json':
            default:
                header('Content-Type: application/json; charset=utf-8');
                echo json_encode($content);
        }
        #		$t->show();
    }
示例#4
0
文件: Login.php 项目: r4mp/Foodle
 function complete()
 {
     $return = FoodleUtils::getURL();
     if (!empty($_REQUEST['return'])) {
         $return = $_REQUEST['return'];
     }
     SimpleSAML_Utilities::redirect($return);
 }
示例#5
0
文件: PageEdit.php 项目: r4mp/Foodle
 protected function saveChanges()
 {
     $this->foodle->updateFromPost($this->user);
     #		echo '<pre>'; print_r($_REQUEST); exit; print_r($this->foodle); exit;
     $this->foodle->acl($this->user, 'write');
     $this->foodle->save();
     if (isset($this->user->email)) {
         $this->sendMail();
     }
     $newurl = FoodleUtils::getUrl() . 'foodle/' . $this->foodle->identifier . '#distribute';
     SimpleSAML_Utilities::redirect($newurl);
     exit;
 }
示例#6
0
    public function execute()
    {
        $text = '
Below follows the latest updates on Foodles you have created.

		';
        foreach ($this->updates as $foodleid => $res) {
            $url = FoodleUtils::getUrl() . 'foodle/' . $res['foodle']->identifier;
            $text .= '
## ' . htmlspecialchars($res['foodle']->name) . '

';
            if (empty($res['updates']['responses'])) {
                $text .= "\n\nNo new responses was registered for this Foodle.\n";
            } else {
                $text .= "\n";
                foreach ($res['updates']['responses'] as $response) {
                    $text .= '* ' . $response->statusline() . "\n";
                }
                $text .= "\n";
            }
            if (empty($res['updates']['discussion'])) {
                $text .= "\nNo new discussion entries was registered for this Foodle.\n";
            } else {
                $text .= "\n";
                foreach ($res['updates']['discussion'] as $discussion) {
                    #print_r($discussion);
                    $text .= "* " . date('l H:i', $discussion['createdu']) . ' ' . $discussion['username'] . " added a discussion entry.\n";
                }
                $text .= "\n";
            }
            $text .= "\n[Go to this foodle to view all responses](" . htmlspecialchars($url) . ")\n\n";
        }
        $profileurl = FoodleUtils::getUrl() . 'profile';
        $text .= '

## Setup your e-mail notification preferences

You can turn of this e-mail notification, and configure other notification messages <a href="' . htmlspecialchars($profileurl) . '">from your Foodle preference page</a>:

	' . htmlspecialchars($profileurl);
        $to = $this->user->email;
        // $to = '*****@*****.**';
        $mailer = new Foodle_EMail($to, 'Daily Foodle status update', 'Foodl.org <*****@*****.**>');
        $mailer->setBody($text);
        $mailer->send();
    }
示例#7
0
 function prepare()
 {
     $config = SimpleSAML_Configuration::getInstance('foodle');
     $entityid = $this->config->getValue('entityid');
     $feeds = $this->config->getArrayize('feeds', array('edugain'));
     $responseurl = FoodleUtils::getUrl() . 'discoresponse';
     $data = array('title' => 'Foodle', 'entityid' => $entityid, 'responseurl' => $responseurl, 'feeds' => $feeds, 'returnurl' => FoodleUtils::getUrl() . '?idp=', 'extrafeed' => FoodleUtils::getUrl() . '/extradiscofeed', 'subIDstores' => array('https://idp.feide.no' => 'https://idp.feide.no/simplesaml/module.php/feide/getOrg.php', "https://wayf.wayf.dk" => "https://wayf.wayf.dk/module.php/wayfdiscopower/disco.php"), 'subIDwritableStores' => array('https://idp.feide.no' => 'https://idp.feide.no/simplesaml/module.php/feide/preselectOrg.php?ReturnTo=' . urlencode(FoodleUtils::getUrl() . '/discoresponse') . '&HomeOrg=', 'https://wayf.wayf.dk' => 'https://wayf.wayf.dk/module.php/wayfdiscopower/disco.php?entityID=https%3A%2F%2Fwayf.wayf.dk&return=https%3A%2F%2Fwayf.wayf.dk%2Fmodule.php%2Fsaml%2Fsp%2Fdiscoresp.php&returnIDParam=idpentityid&idpentityid='), 'baseURL' => FoodleUtils::getUrl());
     // $discojuiceconfig = '
     // 	"Foodle",
     // 	"' . $entityid . '",
     // 	"' . $responseurl . '",
     // 	' . json_encode($feeds) . ',
     // 	"http://foodl.org/?idp="
     // ';
     return $data;
     throw new Exception('Invalid request parameters');
 }
示例#8
0
    protected function sendMail($foodle)
    {
        if (!$this->user->notification('newfoodle', FALSE)) {
            error_log('Foodle was updated, but mail notification was not sent because of users preferences');
            return;
        }
        error_log('Foodle was updated, sending notification!');
        $profileurl = FoodleUtils::getUrl() . 'profile/';
        $url = FoodleUtils::getUrl() . 'foodle/' . $foodle->identifier;
        $name = $foodle->name;
        $to = $this->user->email;
        $mail = '
Hi, your new Foodle named <i>' . htmlspecialchars($name) . '</i> was successfully created.

You may visit your Foodle link below to update your response, and view other responses:

* [Edit your Foodle response](' . $url . ')
* [View responses of other participants](' . $url . '#responses)

If you want so invite others to respond to this Foodle, you should share the link below:

	' . htmlspecialchars($url) . '


### Notifications

You can turn of this e-mail notification, and configure other notification messages <a href="' . htmlspecialchars($profileurl) . '">from your Foodle preference page</a>:

	' . htmlspecialchars($profileurl) . '


### Did you know

You may also create new Foodles on your own, and invite others to respond.

* [Go to Foodl.org to create a new Foodle.](http://foodl.org)

		';
        $mailer = new Foodle_EMail($to, 'New foodle: ' . htmlspecialchars($name), 'Foodl.org <*****@*****.**>');
        $mailer->setBody($mail);
        $mailer->send();
        #echo '<pre>'; print_r($mail); exit;
    }
示例#9
0
文件: RSSFoodle.php 项目: r4mp/Foodle
 function show()
 {
     $url = FoodleUtils::getUrl() . 'foodle/' . $this->foodle->identifier;
     $responses = $this->foodle->getResponses();
     $rssentries = array();
     foreach ($responses as $response) {
         #echo '<pre>'; print_r($response); echo '</pre>';
         $newrssentry = array('title' => $response->username, 'description' => 'Response: ' . self::encodeResponse($response->response['data']), 'pubDate' => $response->created);
         if (isset($entry['notes'])) {
             $newrssentry['description'] .= '<br /><strong>Comment from user: </strong><i>' . $response->notes . '</i>';
         }
         $newrssentry['description'] .= '<br />[ <a href="' . $url . '">go to foodle</a> ]';
         $rssentries[] = $newrssentry;
     }
     $rss = new RSS($this->foodle->name);
     #$rss->description = $this->foodle->description;
     $rsstext = $rss->get($rssentries);
     header('Content-Type: text/xml');
     echo $rsstext;
 }
示例#10
0
文件: Foodle.php 项目: r4mp/Foodle
 public function getExpireText()
 {
     if (empty($this->expire)) {
         return 'This foodle will not expire';
     }
     if ($this->isExpired()) {
         return 'This foodle is expired';
     }
     return date("Y-m-d H:i", (int) $this->expire) . ' (expires in ' . FoodleUtils::date_diff((int) $this->expire - time()) . ')';
 }
示例#11
0
文件: FixDate.php 项目: r4mp/Foodle
    protected function sendFixDateMail($user, $foodle)
    {
        if (!$this->user->notification('invite', TRUE)) {
            error_log('Foodle response was added, but mail notification was not sent because of users preferences');
            return;
        }
        error_log('Sending Foodle fixdate to ' . $user->email);
        $profileurl = FoodleUtils::getUrl() . 'profile/';
        $url = FoodleUtils::getUrl() . 'foodle/' . $foodle->identifier;
        $name = 'Date and time set for ' . $foodle->name;
        if (empty($user->email)) {
            error_log('Was not able to send e-mail notification to ' . $user->userid . ' because email address was missing');
            return;
        }
        $to = $user->email;
        //		$to = '*****@*****.**';
        $datetimetext = '';
        $extralinks = '';
        if (!empty($foodle->datetime)) {
            $tz = new TimeZone($this->db, NULL, $user);
            $icalurl = FoodleUtils::getUrl() . 'foodle/' . $foodle->identifier . '?output=ical';
            $datetimetext = "\n\n### Date and time\n\n" . $foodle->datetimeText($tz->getTimeZone());
            $extralinks = "\n* Import to your calendar using the attached calendar file";
        }
        $mail = $foodle->descr . '

### Confirm your participation

* [Please confirm your participation on this event](' . $url . ')
* [View confirmation of other participants](' . $url . '#responses)' . $extralinks . '

' . $datetimetext . '

### Did you know

You may also create new Foodles on your own, and invite others to respond.

* [Go to Foodl.org to create a new Foodle.](http://foodl.org)

		';
        $mailer = new Foodle_EMail($to, htmlspecialchars($name), 'Foodl.org <*****@*****.**>');
        $mailer->setBody($mail);
        if (!empty($foodle->datetime)) {
            $url = FoodleUtils::getUrl() . 'foodle/' . $foodle->identifier . '?output=ical';
            $ics = file_get_contents($url);
            $mailer->send(array(array('data' => $ics, 'file' => 'foodl-invitation.ics', 'type' => 'calendar/text')));
        } else {
            $mailer->send();
        }
    }
示例#12
0
 public function getAgo()
 {
     if (!empty($this->updated)) {
         return FoodleUtils::date_diff(time() - $this->updated);
     }
     if (!empty($this->created)) {
         return FoodleUtils::date_diff(time() - $this->created);
     }
     return NULL;
 }
示例#13
0
 function show()
 {
     $this->template->data['foodleid'] = $this->foodle->identifier;
     $this->template->data['user'] = $this->user;
     if ($this->user !== null) {
         // $this->template->data['userid'] = $this->user->userid;
         $this->template->data['userToken'] = $this->user->getToken();
     }
     $this->template->data['title'] = 'Foodle :: ' . $this->foodle->name;
     $this->template->data['foodle'] = $this->foodle;
     $this->template->data['optimize'] = $this->config->getValue('optimize', false);
     $this->template->data['gmapsAPI'] = $this->config->getValue('gmapsAPI');
     $this->template->data['authenticated'] = $this->auth->isAuth();
     $this->template->data['loginurl'] = $this->auth->getLoginURL();
     $this->template->data['logouturl'] = $this->auth->getLogoutURL('/');
     $this->template->data['url'] = FoodleUtils::getUrl() . 'foodle/' . $this->foodle->identifier;
     $this->template->data['bread'] = array(array('href' => '/' . $this->config->getValue('baseurlpath'), 'title' => 'bc_frontpage'), array('href' => '/foodle/' . $this->foodle->identifier, 'title' => $this->foodle->name));
     Timer::tick('Presenting page');
     $this->template->data['timer'] = Timer::getList();
     $this->template->show();
 }
示例#14
0
文件: User.php 项目: r4mp/Foodle
 public function getPhotoURL($size = 'm')
 {
     $basepath = $this->config->getPathValue('photodir');
     $basefilename = $this->getToken();
     $file = $basepath . $basefilename . '-' . $size . '.jpeg';
     // error_log('Looking for file : ' . $file);
     if (!file_exists($file)) {
         return FALSE;
     }
     return FoodleUtils::getURL() . 'photo/' . $basefilename . '/' . $size;
 }
示例#15
0
    private function embedIframe()
    {
        return self::wrap('<iframe style="border: 1px solid #999; width: 100%; height: 20em; overflow-y: scroll" 
	src="' . FoodleUtils::getUrl() . 'embed/' . $this->foodle->identifier . '?output=htmliframe" >
</iframe>');
    }
示例#16
0
文件: disco.php 项目: r4mp/Foodle
		<script type="text/javascript">
            var acl = ['foodl.org', 'beta.foodl.org', 'beta2.foodl.org', 'deploy.foodl.org'];
			var djc = DiscoJuice.Hosted.getConfig(<?php 
echo $discojuiceconfig;
?>
);

			djc.overlay = true;
            djc.always = true;
			djc.disco.subIDstores = {
				'https://idp.feide.no': 'https://idp.feide.no/simplesaml/module.php/feide/getOrg.php',
				"https://wayf.wayf.dk": "https://wayf.wayf.dk/module.php/wayfdiscopower/disco.php"
			};

	<?php 
echo "\n\t\t\tdjc.metadata.push('" . FoodleUtils::getUrl() . "/extradiscofeed');\n\t\t\tdjc.disco.subIDwritableStores = {};\n\t\t\tdjc.disco.subIDwritableStores['https://idp.feide.no'] = 'https://idp.feide.no/simplesaml/module.php/feide/preselectOrg.php?ReturnTo=" . urlencode(FoodleUtils::getUrl() . '/discoresponse') . "&HomeOrg=';\n\t\t\tdjc.disco.subIDwritableStores['https://wayf.wayf.dk'] = 'https://wayf.wayf.dk/module.php/wayfdiscopower/disco.php?entityID=https%3A%2F%2Fwayf.wayf.dk&return=https%3A%2F%2Fwayf.wayf.dk%2Fmodule.php%2Fsaml%2Fsp%2Fdiscoresp.php&returnIDParam=idpentityid&idpentityid=';\n\n\n\t\t";
?>

			djc.callback = IdPDiscovery.setup(djc, acl);
			
			$(document).ready(function() {
				$("a.signin").DiscoJuice(djc);
			});

		</script>





示例#17
0
    private function sendEmail()
    {
        $fromAddress = $this->config->getValue('fromAddress', '*****@*****.**');
        $url = FoodleUtils::getUrl() . '?sessionBootstrap=' . $this->bootstrap;
        $message = '<h2>Foodle</h2><p>It seems like you have been using Foodle for the first time. Welcome!
			<p>You have been using Foodle as an anonymous user, and we send you this e-mail so that you can
			edit your Foodle response by going to the special URL below.</p>
			<p>We strongly reccomend that instead of using Foodle as a anonymous user, you use the login button
			to login to your home institusions user ID. If you do not have an user accout, you may create one for free, by
			using the Feide Guest IdP.</p>
			
			<p>The URL to edit your Foodle response is:</p>
			
			<p><tt>' . htmlspecialchars($url) . '</tt></p>
			
			<p><a href="' . htmlspecialchars($url) . '">Go here to edit your Foodle</a></p>
		';
        $email = new SimpleSAML_XHTML_EMail($this->user->email, 'Welcome to Foodle', $fromAddress);
        $email->setBody($message);
        $email->send();
    }
示例#18
0
 public function readDiscussion(Data_Foodle $foodle, $maxago = null)
 {
     $maxclause = '';
     if ($maxago !== null) {
         $maxclause = ' AND UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(created) < ' . mysql_real_escape_string($maxago);
     }
     $sql = "\n\t\t\tSELECT *, UNIX_TIMESTAMP(created) AS createdu\n\t\t\tFROM discussion \n\t\t\tWHERE foodleid = '" . $foodle->identifier . "' " . $maxclause . "\n\t\t\tORDER BY discussion.created DESC \n\t\t\t";
     $result = $this->q($sql);
     $discussion = array();
     if (!empty($result)) {
         foreach ($result as $row) {
             try {
                 if (!empty($row['userid'])) {
                     $ruser = $this->readUser($row['userid']);
                     if ($ruser !== false) {
                         $row['user'] = $ruser;
                     }
                 }
             } catch (Exception $e) {
             }
             $row['agotext'] = FoodleUtils::date_diff(time() - $row['createdu']);
             $discussion[] = $row;
         }
     }
     return $discussion;
 }