/** * Create new RSS file after project creation * @param $project * @return bool */ public function storeProjectRssFile(Project $project) { $fileName = $this->rssDir . $this->pKey . ".rss"; $rssLog = new Rss_log(); $rssLog->setPid($project->getId()); if (!$this->checkFileExists($fileName)) { // Create new one RSS file $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"></rss>', null, false); $channel = $xml->addChild("channel"); $channel->addChild("title", $project->getName()); $channel->addChild("description", $project->getDescription()); $channel->addChild("link", $this->partnerUrl . $project->getCruid()); $rssLog->setTitle($project->getName()); $rssLog->setDescription($project->getDescription()); $rssLog->setLink($this->partnerUrl . $project->getCruid()); $rssLog->setType("project create"); } else { // Update existing RSS file libxml_use_internal_errors(true); try { $xml = new SimpleXMLElement($fileName, NULL, TRUE); } catch (Exception $er) { return false; } $xml = $this->openRssFile($fileName); if ($xml === false) { return false; } unset($xml->channel->title); unset($xml->channel->description); unset($xml->channel->link); $xml->channel->addChild("title", $project->getName()); $xml->channel->addChild("description", $project->getDescription()); $xml->channel->addChild("link", $this->partnerUrl . $project->getCruid()); $rssLog->setTitle($project->getName()); $rssLog->setDescription($project->getDescription()); $rssLog->setLink($this->partnerUrl . $project->getCruid()); $rssLog->setType("project update"); } try { $xml->asXML($fileName); } catch (Exception $er) { return false; } $rssLog->setR_date(\Carbon\Carbon::Now()->toDateTimeString()); $this->storeRssLog($rssLog); return true; }
public function InsertNewProject(Project $p = null) { if ($p == null || !$p instanceof Project) { return null; } $props = array("UserID," => $p->getUserID(), "ClientID," => $p->getClientID(), "Title," => $p->getTitle(), "Description," => $p->getDescription(), "TotalWorkHours," => $p->getTotalWorkHours(), "TotalEstimateHours," => $p->getTotalEstimateHours(), "DateCreated" => $p->getDateCreated()); foreach ($props as $k => $v) { if ($v != null) { if ($k == "DateCreated") { $_props[$k] = "'" . $v . "'"; } else { if (gettype($v) == "string") { $_props[$k] = "'" . $v . "', "; } else { $_props[$k] = "{$v}, "; } } } } $this->_dbAdapt->IStatement($this->dbTbl, $_props); $tmp = $this->_dbAdapt->getLnk(); $tmp->query($this->_dbAdapt->getQry()); unset($tmp); return true; }
private function workspace_toxml(Project $ws, $activeProjects) { $parentIds = ''; $i = 1; $pid = $ws->getPID($i); while ($pid != $ws->getId() && $pid != 0 && $i <= 10) { $coma = $parentIds == '' ? '' : ','; if (in_array($pid, $activeProjects)) { $parentIds .= $coma . $pid; } $i++; $pid = $ws->getPID($i); } $this->instance->startElement('workspace'); $this->instance->startElement('id'); $this->instance->text($ws->getId()); $this->instance->endElement(); $this->instance->startElement('name'); $this->instance->text($ws->getName()); $this->instance->endElement(); $this->instance->startElement('description'); $this->instance->text($ws->getDescription()); $this->instance->endElement(); $this->instance->startElement('parentids'); $this->instance->text($parentIds); $this->instance->endElement(); $this->instance->endElement(); }
private function exportProjectInfo(Project $project, SimpleXMLElement $project_node) { $access_value = $project->isPublic() ? Project::ACCESS_PUBLIC : Project::ACCESS_PRIVATE; $project_node->addAttribute('unix-name', $project->getUnixName()); $project_node->addAttribute('full-name', $project->getPublicName()); $project_node->addAttribute('description', $project->getDescription()); $project_node->addAttribute('access', $access_value); $project_node->addChild('long-description', ''); $services_node = $project_node->addChild('services'); foreach ($project->getServices() as $service) { $service_node = $services_node->addChild('service'); $service_node->addAttribute('shortname', $service->getShortName()); $service_node->addAttribute('enabled', $service->isUsed()); } }
/** * Print the project description, if any */ public static function printDescription(Project $project) { if ($project->getDescription() !== null) { self::$out->write($project->getDescription() . PHP_EOL); } }
require './header.php'; $cards = fRecordSet::build('Card', array('uid=' => $_GET['cardid'])); if ($cards->count() == 0) { fURL::redirect("/kiosk/addcard.php?cardid=" . $_GET['cardid']); } $card = $cards->getRecord(0); $user = new User($card->getUserId()); $user->load(); if (isset($_POST['print'])) { $project = new Project($_POST['print']); $project->load(); if ($project->getUserId() != $user->getId()) { print "Incorrect project ID"; exit; } $data = array('storage_id' => $project->getId(), 'name' => $project->getName(), 'ownername' => $user->getFullName(), 'more_info' => $project->getDescription(), 'completion_date' => $project->getToDate()->format('Y/m/d'), 'max_extention' => "14"); $data_string = json_encode($data); $ch = curl_init('http://kiosk.london.hackspace.org.uk:12345/print/dnh'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string))); $result = curl_exec($ch); curl_close($ch); echo "<p>Your sticker is being printed now.</p>"; } $projects = fRecordSet::build('Project', array('state_id!=' => array('6', '7'), 'user_id=' => $user->getId())); ?> <?php if ($projects->count() > 0) {
" class="btn btn-default">Print DO NOT HACK label</a><br/> <?php } ?> <br/> <?php if ($project->hasExtension()) { ?> <strong>Extended for <?php echo $project->getExtensionDuration(); ?> days</strong><br/><br/><?php } ?> <p><?php echo nl2br(stripslashes($project->getDescription())); ?> </p> <br/> <hr/> <strong>Activity log</strong><br/><br/> <ul> <?php foreach ($projectslogs as $log) { $userURL = ''; if ($log->getUserId() != null) { $logUser = new User($log->getUserId()); $userURL = ' by <a href="/members/member.php?id=' . $log->getUserId() . '">' . htmlspecialchars($logUser->getFullName()) . '</a>'; } echo '<li><span class="light-color">' . date('g:ia jS M', $log->getTimestamp()) . '</span> | ' . str_replace('Mailing List', '<a target="_blank" href="' . $project->getMailingListURL() . '">Mailing List</a>', $log->getDetails()) . $userURL . '</li>'; }
/** Print the project description, if any */ function printDescription(Project $project) { if ($project->getDescription() !== null) { print $project->getDescription() . "\n"; } }
class Project { protected $description; public function setDescription($description) { $this->description = $description; return $this; } public function getDescription() { return $this->description; } } $project_one = new Project(); $project_one->setDescription("This is my first test project"); echo $project_one->getDescription(); echo "<br>"; $project_two = $project_one; // Copying by value? echo $project_two->getDescription(); echo "<br>"; $project_two->setDescription("This is my second test project"); echo $project_two->getDescription(); echo "<br>"; echo $project_one->getDescription(); echo "<br>"; echo "Cloning.."; $project_three = clone $project_one; echo $project_three->getDescription(); $project_three->setDescription("This is my third test project"); echo "<br>";
/** * Print the project description, if any */ public static function printDescription(Project $project) { if ($project->getDescription() !== null) { self::$out->write($project->getDescription() . self::getProperty("line.separator")); } }
?> )</option> <?php } ?> </select> <?php foreach ($levels as $level) { $level = new Project($level->ID); ?> <div id="supportLevel<?php echo $level->getID(); ?> " class="modal-support-level" style="display:none"> <?php echo $level->getDescription(); ?> <?php echo $level->getPaypalForm(array('return' => home_url('thank-you'))); ?> </div> <?php } ?> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div>
function actionSave($currentUser) { $backUrl = $this->context->getFlowScopeAttr("backUrl"); $oldRssKey = null; $project = new Project(); $projectErrs = array(); $project->setId($this->context->getRequestAttr("id")); if (!is_null($project->getId())) { $oldProject = $this->projectDao->get($project->getId()); if (is_null($oldProject) || is_string($oldProject)) { $this->context->setRequestScopeAttr("error", "error.dberror"); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } } $project->setName($this->context->getRequestAttr("name")); if (!is_null($project->getName())) { $project->setName(trim($project->getName())); if (strlen($project->getName()) < 1) { $project->setName(null); } } if (is_null($project->getName())) { $projectErrs["name"] = "field.error.empty"; } $project->setDescription($this->context->getRequestAttr("description")); if (!is_null($project->getDescription())) { $project->setDescription(trim($project->getDescription())); if (strlen($project->getDescription()) < 1) { $project->setDescription(null); } } $project->setCampaign($this->context->getRequestAttr("campaign")); if (!is_null($project->getCampaign())) { $project->setCampaign(trim($project->getCampaign())); if (strlen($project->getCampaign()) < 1) { $project->setCampaign(null); } } $project->setSuspending($this->context->getRequestAttr("suspending")); if (!is_null($project->getSuspending())) { $project->setSuspending(trim($project->getSuspending())); if (strlen($project->getSuspending()) < 1) { $project->setSuspending(null); } } $project->setEnding($this->context->getRequestAttr("ending")); if (!is_null($project->getEnding())) { $project->setEnding(trim($project->getEnding())); if (strlen($project->getEnding()) < 1) { $project->setEnding(null); } } $move_more = $this->context->getRequestAttr("move_more"); $project->setMove_more($move_more == 1 ? true : false); $timeZone = new DateTimeZone("Europe/Vilnius"); $time = new DateTime("now", $timeZone); $project->setR_date($time->format("Y-m-d H:i:s")); $project->setR_user($currentUser->getId()); if (is_null($project->getId())) { $project->setOwner($currentUser->getId()); $project->setCruid($this->generateCode()); $project->setPkey($this->generateCode()); $project->setRsskey($this->generateCode()); } else { $project->setCruid($oldProject->getCruid()); $project->setRsskey($oldProject->getRssKey()); } $this->context->setFlashScopeAttr("project", $project); $this->context->setFlashScopeAttr("projectErrs", $projectErrs); if (count($projectErrs) >= 1) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } $store = $this->storeProject($project); if (!$store) { if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; } $rss = new Rss($project->getRsskey()); if (!$rss->storeProjectRssFile($project)) { $this->context->setRequestScopeAttr("errortxt", "Nepavyko sukurti/atnaujinti RSS failo!"); } /* Issaugom pasirinktas grupes */ $groups = $this->context->getRequestAttr("groups"); $selectedProjects = $this->context->getRequestAttr("selectedProjects"); if (is_null($selectedProjects) && !is_null($groups)) { $this->saveProjectGroups($project->getId(), $groups); } if (!is_null($selectedProjects) && is_null($groups)) { $this->removeProjectFromGroups($currentUser->getId(), $project->getId()); } if (!is_null($selectedProjects) && !is_null($groups)) { $toRemove = array_diff(json_decode($selectedProjects), $groups); if (count($toRemove) > 0) { foreach ($toRemove as $gp) { $this->removeFromGroup($gp, $project->getId()); } } $toAdd = array_diff($groups, json_decode($selectedProjects)); if (count($toAdd) > 0) { $this->saveProjectGroups($project->getId(), $toAdd); } } $this->cancelEdit(); if (!is_null($backUrl)) { header("Location: " . $backUrl); return true; } return false; }
$auto = true; $logDetails = "Request created"; $project->setState('Pending Approval'); $initial = true; } else { $auto = false; $logDetails = "Request updated"; $initial = false; } $project->setUpdatedDate(date('Y-m-d')); $project->setUserId($user->getId()); $project->store(); $project->submitLog($logDetails, $user->getId()); // post to Google Groups $projectUser = new User($project->getUserId()); $message = '<strong>' . $project->getName() . "</strong><br>\n" . "https://london.hackspace.org.uk/storage/" . $project->getId() . "<br>\n" . "by <a href=\"https://london.hackspace.org.uk/members/member.php?id=" . $project->getUserId() . "\">" . htmlspecialchars($projectUser->getFullName()) . "</a><br>\n" . $project->outputDates() . "<br>\n" . $project->outputDuration() . ' ' . $project->outputLocation() . "<br>\n<br>\n" . nl2br(stripslashes($project->getDescription())) . "<br>\n<br>\n"; if ($auto && !$project->isShortTerm()) { $message .= "<strong>***If no one replies to this topic the request will be automatically approved within " . $project->automaticApprovalDuration() . " days.***</strong>"; } $project->submitMailingList($message, $initial); // is this a short term request? If so automatically approve it if ($project->isShortTerm()) { $project->setState('Approved'); $project->store(); // log the update $logmsg = 'Short term storage detected, status automatically changed to ' . $project->getState(); $project->submitLog($logmsg, false); $project->submitMailingList($logmsg); } fURL::redirect("/storage/{$project->getId()}"); } catch (fValidationException $e) {
public function SaveProjectEdits() { //$tmp = BasicAuthService::EntryPointCheck(); $tmpProject = new Project((int) $_REQUEST["ProjectId"], $_SESSION["User"]->getUID(), (int) $_REQUEST["ClientID"], $_REQUEST["Title"], $_REQUEST["Description"], (double) $_REQUEST["TotalWorkHours"], (double) $_REQUEST["TotalEstimateHours"], $_REQUEST["DateCreated"]); $GLOBALS["App"]["ServiceAdapter"] = $this->_projectServiceAdpt; $tmpSetup = array("EditProjectUserId" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getUserID()), "EditProjectClientId" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getClientID()), "EditProjectTitle" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getTitle()), "EditProjectDescription" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getDescription()), "EditProjectTotalWorkHours" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getTotalWorkHours()), "EditProjectTotalEstimateHours" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getTotalEstimateHours()), "EditProjectDateCreated" => array(0 => $tmpProject->getId(), 1 => $tmpProject->getDateCreated())); $failures = array(); $GLOBALS["App"]["Error"] = ""; foreach ($tmpSetup as $updateMethod => $parameters) { $success = $this->_projectServiceAdpt->{$updateMethod}($parameters[0], $parameters[1]); if (!$success) { $stringd = "++ {$updateMethod} failed with parameters: {$parameters['0']} and {$parameters['1']} ++"; $GLOBALS["App"]["Error"] .= "++ {$stringd} ++"; $failures[] = $stringd; } } $this->PostEditCallBack(count($failures) == 0 ? null : $failures); }