예제 #1
0
파일: test.php 프로젝트: NemOry/CloudText
<?php

$version = 0;
if (isset($_GET['version'])) {
    $version = $_GET['version'];
}
$announcements = array();
$announcement = new Announcement();
$announcement->version = "0.0.3.1";
$announcement->message = "version 1";
array_push($announcements, $announcement);
$theannouncement = new Announcement();
$theannouncement->version = $version;
$theannouncement->message = getAnnouncement($version, $announcements);
echo json_encode($theannouncement);
function getAnnouncement($version, $announcements)
{
    $returnedAnnouncment = "version 0 Default";
    foreach ($announcements as $object) {
        if ($object->version == $version) {
            $returnedAnnouncment = $object->message;
            break;
        }
    }
    return $returnedAnnouncment;
}
class Announcement
{
    public $message;
    public $version = 0;
}
예제 #2
0
 function getMyAnnouncements()
 {
     $conn = getConnection();
     $list = array();
     $query = "SELECT * FROM announcement WHERE batchID='" . $this->BatchID . "' AND activeflag=1 ORDER BY lastupdated DESC";
     $result = mysql_query($query);
     while ($member = mysql_fetch_array($result)) {
         $temp = getAnnouncement($member['ID']);
         array_push($list, $temp);
     }
     if (count($list) != 0) {
         return $list;
     }
     return NULL;
 }
function updateAnnouncement($ID, $name, $activeflag, $id)
{
    $conn = getConnection();
    $Obj = getAnnouncement($ID);
    $Obj->setDisplay($name);
    $Obj->setActiveFlag($activeflag);
    $Obj->setCreatedBy($id);
    $result = $Obj->update();
    if ($result) {
        $message = "Announcement Updated Successfully :" . $name;
    } else {
        $message = "Announcement Updation Failed : " . $name;
    }
    return $message;
}