function delete() { Category::requirePermission("DELETE"); $link = Database::getConnection(); $query = "DELETE FROM category WHERE id=".Database::sqlValue($this->id); mysql_query($query) or die(Database::formatError($query, Text::getText("QueryFailed"))); Database::returnConnection($link); }
function printContent() { ?> <table border="0"> <tr bgcolor=<?=BGCOLOR_ALT?>> <th>#</th> <? if (SecurityGroup::havePermission("DELETE")) { ?> <th></th> <? } ?> <th><?=Text::getText("Name")?></th> <th> </th> <th> </th> </tr> <? $bg = TRUE; ?> <? foreach ($this->groups as $g) { ?> <? $bg = !$bg; ?> <tr<? if ($bg) { ?> bgcolor=<?=BGCOLOR_ALT?><? } ?>> <td> <?=$g->getId()?> </td> <? if (SecurityGroup::havePermission("DELETE")) { ?> <td><a href="<?=$this->groupDeletePage?>?<?=$this->groupDeleteParamGroupId?>=<?=$g->getId()?>" onClick="return confirm('<?=Text::getText('ConfirmDeleteGroup')?>')"><img src="<?=$this->imgDeleteSrc?>" border="0" alt="<?=Text::getText('Delete')?>"></a></td> <? } ?> <td> <a href="<?=$this->groupEditPage?>?<?=$this->groupEditParamGroupId?>=<?=$g->getId()?>"><?=$g->getName()?></a> </td> <td> <a href="<?=$this->groupMembersPage?>?<?=$this->groupMembersParamGroupId?>=<?=$g->getId()?>"><?=Text::getText("Members")?></a> </td> <td> <a href="<?=$this->groupPermissionsPage?>?<?=$this->groupPermissionsParamGroupId?>=<?=$g->getId()?>"><?=Text::getText("Permissions")?></a> </td> </tr> <? } ?> </table> <? }
function printContent() { $action = $this->getAction(); ?> <form method="POST" action="<?=$action?>"> <input type="hidden" name="action" value="save"> <input type="hidden" name="submitted" value="yes"> <table border="0" cellpadding="2"> <tr> <th><?=Text::getText("LoginName")?></th> <td><input type="text" name="loginName" value=""></td> </tr> <tr> <th><?=Text::getText("FullName")?></th> <td><input type="text" name="fullName" value=""></td> </tr> <tr> <th><?=Text::getText("Password")?></th> <td><input type="password" name="password" value=""></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="<?=Text::getText("Add")?>"> </td> </tr> </table> </form> <? }
function printContent() { ?> <table border="0"> <tr bgcolor="<?=BGCOLOR_ALT?>"> <th>#</th> <? if (SecurityUser::havePermission("DELETE")) { ?> <th></th> <? } ?> <th><?=Text::getText("FullName")?></th> <th><?=Text::getText("LoginName")?></th> </tr> <? $bg = TRUE; ?> <? foreach ($this->users as $u) { ?> <? $bg = !$bg; ?> <tr<? if ($bg) { ?> bgcolor="<?=BGCOLOR_ALT?>"<? } ?>> <td> <?=$u->getId()?> </td> <? if (SecurityUser::havePermission("DELETE")) { ?> <td><a href="<?=$this->userDeletePage?>?<?=$this->userDeleteUserParam?>=<?=$u->getId()?>" onClick="return confirm('<?=Text::getText('ConfirmDeleteUser')?>\n\n<?=$u->getLoginName()?>')"><img src="<?=IMAGE_TRASH?>" border="0" alt="<?=Text::getText('Delete')?>"></a></td> <? } ?> <td> <?=$u->getFullName()?> </td> <td> <a href="<?=$this->getUserPage()?>?id=<?=$u->getId()?>"><?=$u->getLoginName()?></a> </td> </tr> <? } ?> </table> <? }
/** * */ function getSubmitCaption() { if ($this->submitCaption == NULL) { return Text::getText("Submit"); } else { return $this->submitCaption; } }
/** * Takes an INSERT query and returns the inserted ID, * or 0 if query does not generate an AUTO_INCREMENT * value. */ function insert($sql) { $con = Database::getConnection(); $result = mysql_query($sql) or die(Database::formatError($sql, Text::getText("QueryFailed"))); $record = new DatabaseRecord($result); $id = mysql_insert_id($con); Database::returnConnection($con); return $id; }
/** * __construct() should return text element if text is string */ public function testConstruct_returnsElement_ifTextIsString() { $string = 'foo'; $text = new Text($string); $this->assertTrue($text instanceof Text); $this->assertEquals($string, $text->getText()); return; }
public function testFormattedTextRetrieve() { $string = "Hey %s, you have %d new messages"; $arg1 = "Joe"; $arg2 = 15; $compare = "Hey Joe, you have 15 new messages"; $retrieved = Text::getText($string, $arg1, $arg2); self::assertSame($compare, (string) $retrieved); }
protected function writeText(Text $textChild, $level) { $newLine = $this->_pretty ? $this->_newLine : ''; $indent = $this->_pretty ? str_repeat($this->_tabString, $level) : ''; $text = $textChild->getText(); //TODO: Need some kind of mb_wordwrap here, maybe: //http://stackoverflow.com/questions/3825226/multi-byte-safe-wordwrap-function-for-utf-8? return $this->_pretty && mb_strlen($text, 'utf-8') > $this->_textWrap ? $indent . wordwrap(str_replace("\n", '', $text), $this->_textWrap, "{$newLine}{$indent}") : $text; }
function update() { SecurityGroup::requirePermission("CHANGE"); if ($this->id == NULL) { die(Text::getText("GroupHasNoId")); } $query = "UPDATE security_group"; $query .= " SET name=".Database::sqlValue($this->name); $query .= " WHERE id=".Database::sqlValue($this->id); Database::query($query); }
function printContent() { $u = $this->getUser(); ?> <form method="POST"> <input type="hidden" name="action" value="save"> <table border="0" cellpadding="2"> <tr> <td colspan="2" align="center"> <?=Text::getText("UserInfo")?> </td> </tr> <tr> <th><?=Text::getText("LoginName")?></th> <td><input type="text" name="loginName" value="<?=$u->getLoginName()?>"></td> </tr> <tr> <th><?=Text::getText("FullName")?></th> <td><input type="text" name="fullName" value="<?=$u->getFullName()?>"></td> </tr> <tr> <td colspan="2" align="center"> </td> </tr> <tr> <td colspan="2" align="center"> <input type="checkbox" name="changePassword" value="true"> <?=Text::getText("ChangePassword")?> </td> </tr> <tr> <th><?=Text::getText("NewPassword")?></th> <td><input type="password" name="password" value=""></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="<?=$this->getSubmitCaption()?>"> <input type="button" value="<?=Text::getText('Cancel')?>" onClick="document.location='<?=$this->cancelPage?>'"> </td> </tr> </table> </form> <? }
function printContent() { ?> <form method="POST" action="<?=$this->getAction()?>"> <input type="hidden" name="action" value="save"> <table border="0" cellpadding="2"> <tr> <th><?=Text::getText("Name")?></th> <td><input type="text" name="name" value=""></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="<?=Text::getText("Add")?>"> </td> </tr> </table> </form> <? }
function printContent() { $g = $this->group; ?> <form action="<?=$this->getAction()?>" method="POST"> <input type="hidden" name="action" value="save"> <table border="0" cellpadding="2"> <tr> <th><?=Text::getText("Name")?></th> <td><input type="text" name="name" value="<?=$g->getName()?>"></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="<?=Text::getText('Save')?>"> <input type="button" value="<?=Text::getText('Cancel')?>" onClick="document.location='<?=$this->cancelPage?>'"> </td> </tr> </table> </form> <? }
function printContent() { $g = $this->getGroup(); $allPermissions = SecurityPermission::getAll(); $allResources = SecurityResource::getAll(); $msg = $this->getMessage(); ?> <form action="<?=$this->getAction()?>" method="post"> <input type="hidden" name="group" value="<?=$g->getId()?>"> <? if (strlen($msg) > 0) { ?> <p><b><?=$msg?></b></p> <? } ?> <p> <table border="0"> <tr> <td> <table border="0"> <tr bgcolor="<?=BGCOLOR_ALT?>"> <th><?=Text::getText("Resource")?></th> <? foreach ($allPermissions as $perm) { ?> <th><?=$perm->getName()?></th> <? } ?> </tr> <? $bg = TRUE; ?> <? foreach ($allResources as $res) { ?> <? $bg = !$bg; ?> <tr<? if ($bg) { ?> bgcolor="<?=BGCOLOR_ALT?>"<? } ?>> <td><?=$res->getName()?></td> <? foreach ($allPermissions as $perm) { ?> <? $checked = ""; if ($g->hasPermission($res, $perm)) { $checked = " checked"; } ?> <td align="center"><input type="checkbox"<?=$checked?> name="res<?=$res->getId()?>_perm<?=$perm->getId()?>"></td> <? } ?> </tr> <? } ?> </table> </td> </tr> <tr> <td align="center"> <input type="submit" value="<?=Text::getText("Save")?>"> </td> </tr> </table> </p> </form> <? }
</h2> <form method="POST"> <input type="hidden" name="action" value="save"> <table border="0" cellpadding="2"> <tr> <th><?php echo Text::getText("Name"); ?> </th> <td><input type="text" name="name" value="<?php echo $g->getName(); ?> "></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="<?php echo Text::getText("Save"); ?> "> <input type="button" value="<?php echo Text::getText("Cancel"); ?> " onClick="document.location='groups.php'"> </td> </tr> </table> </form>
if ($u == NULL) { $errMsg = Text::getText("MissingUser"); include("error.php"); exit; } if ($action == "save") { if (strlen($loginName) > 0) { $u->setLoginName($loginName); $u->setFullName($fullName); if ($changePassword == "true") { $u->setPassword($password); } $u->save(); header("Location: users.php"); } else { $errMsg = Text::getText("MissingLoginName"); $buttonCaption = Text::getText("Save"); include("header.php"); include("userEditForm.php"); include("footer.php"); } } else { $title = Text::getText("EditUser"); $buttonCaption = Text::getText("Save"); include("header.php"); include("userEditForm.php"); include("footer.php"); } ?>
<? require_once("config.php"); ?> <? require_once(RESACCMAN_BASE."/classes/SecurityUser.php"); ?> <? require_once(RESACCMAN_BASE."/classes/Text.php"); ?> <? $u = SecurityUser::getById($id); if ($u == NULL) { $errMsg = Text::getText("UserNotFound"); $title = Text::getText("Delete"); include("error.php"); } else { $u->delete(); header("Location: users.php"); } ?>
success($user, $pageAfterLogin); } } } else if ($action == "remind") { $user = SecurityUser::getByLoginName($loginName); if ($user == NULL) { $errMsg = Text::getText("UserNotFound"); } else { if ($user->getEmail() == "") { $errMsg = Text::getText("NoEmailSetInProfile"); } else { $user->sendPasswordReset(); $errMsg = str_replace('$email', $user->getEmail(), Text::getText("PasswordResetSent")); } } } else if ($_REQUEST['reset'] != null) { $resetKey = $_REQUEST['reset']; $user = SecurityUser::getByResetKey($resetKey); if ($user == NULL) { $errMsg = Text::getText("InvalidRequestKey"); } else { $errMsg = Text::getText("EnterNewPassword"); $form = "passwordResetForm.php"; } } include("header.php"); include($form); include("footer.php"); ?>
</table> <? if (SecurityGroup::havePermission("ADD")) { ?> <h3><?php echo Text::getText("AddGroup"); ?> </h3> <form method="POST" action="groupAdd.php"> <input type="hidden" name="action" value="save"> <table border="0" cellpadding="2"> <tr> <th><?php echo Text::getText("Name"); ?> </th> <td><input type="text" name="name" value=""></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="<?php echo Text::getText("Add"); ?> "> </td> </tr> </table> </form> <? } ?> <? include("footer.php"); ?>
<? if (Recipe::havePermission("CHANGE")) { ?> <tr> <td colspan="5"> <input type="submit" value="<?php echo Text::getText("Save"); ?> "> </td> </tr> <? } ?> </table> </p> </form> <? } else { ?> <? if ($c == NULL) { ?> <?php echo Text::getText("NoRecipes"); ?> <? } else { ?> <?php echo Text::getText("NoRecipesInCategory"); ?> <? } ?> <? } ?> </p> <div id="rss"><?php echo sprintf(Text::getText("ListAvailableInRSS"), '<a href="' . $rssUrl . '">RSS</a>'); ?> .</div> <? include("footer.php"); ?>
</a> </font> </td> </tr> <? } ?> <tr bgcolor="<?php echo $bgcolor; ?> "> <td align="center"> <font size="<?php echo $fontSize; ?> "> <a href="login.php"><?php echo Text::getText("Login"); ?> </a> </font> </td> </tr> <tr bgcolor="#000000"> <th align="center"> <font color="<?php echo $color; ?> " size="1"> - - - </font> </th> </tr>
<?php require_once "config.php"; require_once RESACCMAN_BASE . "/classes/SecurityUser.php"; require_once RESACCMAN_BASE . "/classes/Text.php"; require_once RESACCMAN_BASE . "/classes/html/UserList.php"; require_once RESACCMAN_BASE . "/classes/html/UserAddForm.php"; include "header.php"; ?> <h2><?php echo Text::getText("Users"); ?> </h2><? $allUsers = SecurityUser::getAll(); $list = new UserList($allUsers); $list->printContent(); if (SecurityUSer::havePermission("ADD")) { $form = new UserAddForm(); $form->printContent(); } include("footer.php"); ?>
/** * Static function that tries to log the specified user in. * * @return LoginResult */ function login($username, $password) { if (strlen($username) > 0) { $user = SecurityUser::getByLoginName($username); if ($user == NULL) { return new LoginResult(FALSE, Text::getText("UserNotFound")); } else { if ($user->verifyPassword($password)) { SecurityUser::setCurrent($user); return new LoginResult(TRUE); } else { return new LoginResult(FALSE, Text::getText("BadPassword")); } } } else { return new LoginResult(FALSE, Text::getText("NoUserSpecified")); } }
</div> </td> </tr> <tr> <th valign="top"><?php echo Text::getText("Picture"); ?> </th> <td><input type="file" name="photo"/></td> </tr> <tr> <td colspan="2" align="center"> <? $label = Text::getText("Back"); $recipeCat = $r->getCategory(); if ($recipeCat != NULL) { $label .= ": ".$recipeCat->getName(); } ?> <input type="button" value="<?php echo $label; ?> " onClick="document.location='./?cat=<?php echo $r->getCategoryId(); ?> #<?php echo $r->getId(); ?> '">
function getUpdateMask() { $tNames = $this->LABELS; $colNames = $this->COLNAMES; array_push($colNames, "Aktion"); array_push($tNames, " "); $table = new Table($tNames); if (count($this->COLSIZES) > 0) { $table->setColSizes($this->COLSIZES); } if (count($this->ALIGNMENTS) > 0) { $table->setAlignments($this->ALIGNMENTS); } if (isset($_REQUEST["showUpdateMask" . $this->TABLENAME]) && strlen($_REQUEST["showUpdateMask" . $this->TABLENAME]) > 0) { $r = $table->createRow(); $r->setSpawnAll(true); $r->setAttribute(0, $this->getSingleUpdateMask($_REQUEST["showUpdateMask" . $this->TABLENAME])); $rX = $table->getRow(0); $table->setRow(0, $r); $table->addRow($rX); $table->addSpacer(0, 15); } $table->setHeadEnabled($this->HEAD_ENABLED); $table->setBackgroundColorChange(true); if ($this->isDeleteInUpdate()) { $this->doDeleteFromUpdatemask(); for ($i = 0; $i < count($tNames); $i++) { if ($i != count($tNames) - 1) { $tmpW[$i] = ""; } else { $tmpW[$i] = "125"; } } $table->setColSizes($tmpW); } if ($this->WIDTH > 0) { $table->setWidth($this->WIDTH); } if ($this->HEIGHT > 0) { $table->setHeight($this->HEIGHT); } if ($this->BORDER != null && strlen($this->BORDER) > 0) { $table->setBorder($this->BORDER); } if ($this->PADDING >= 0) { $table->setPadding($this->PADDING); } if ($this->HEAD_ENABLED) { $table->setHeadEnabled($this->HEAD_ENABLED); } if ($this->SPACING >= 0) { $table->setSpacing($this->SPACING); } if ($this->XPOS > 0 && $this->YPOS > 0) { $table->setXPos($this->XPOS); $table->setYPos($this->YPOS); } //--------------------------------------------------- // gesamte Tabelle einlesen um Feldtypen zu ermitteln //--------------------------------------------------- $stmnt = "SELECT " . $this->COLNAMESTRING . " FROM " . $this->TABLENAME . " LIMIT 1 "; $result = $this->DBCONNECT->executeQuery($stmnt); //--------------------------------------------------- // ROWS in Table aufnehmen //--------------------------------------------------- $bgCtr = 1; for ($ir = 1; $ir <= count($this->ROWS); $ir++) { $r = $table->createRow(); $r->setStyle("padding", "5px 5px"); for ($ia = 0; $ia < count($this->COLNAMES); $ia++) { $row = $this->ROWS[$ir]; $rowId = $this->ROWS[$ir]->getAttribute(count($this->COLNAMES)); $val = ""; $t = ""; if (strlen($row->getAttribute($ia)) > 0) { $val = getDbComboValue($this->TABLENAME, $this->COLNAMES[$ia], $row->getAttribute($ia), $row); } // Wenn DbCombo definiert wurde wird der passende Text zum Code der Spalte angezeigt if (strlen($val) > 0) { $t = $val; } else { $t = $row->getAttribute($ia); } $txt = new Text($t); if (mysql_field_type($result, $ia) == "blob") { $txt = new Text("..."); $fn = mysql_field_name($result, $ia); $txt->setToolTip("<b>" . $fn . ":</b> " . $t); } else { if (mysql_field_type($result, $ia) == "date") { $txt->setText($txt->getText()); } else { //Maximal ersten 30Stellen anzeigen if (strlen($t) > 30) { $tmp = $t; if (strtolower($this->COLNAMES[$ia]) == "email") { $tmp = "<a href='mailto:" . $t . "'>" . substr($t, 0, 30) . "..." . "</a>"; } $txt->setFilter(false); $txt->setText($tmp); $txt->setToolTip($t); } else { $tmp = $t; if (strtolower($this->COLNAMES[$ia]) == "email") { $tmp = "<a href='mailto:" . $t . "'>" . $t . "</a>"; } $txt->setFilter(false); $txt->setText($tmp); } } } if (!$this->isInvisibleCol($this->COLNAMES[$ia])) { $r->setAttribute($ia, $txt); } else { $r->setAttribute($ia, " "); } } $tblBtns = new Table(array("", "")); $tblBtns->setWidth(150); $frmUpdBtn = new Form(); $frmUpdBtn->add($this->DEFAULT_HIDDEN_FIELDS); $frmUpdBtn->add(new Hiddenfield("showUpdateMask" . $this->TABLENAME, $rowId)); $frmUpdBtn->add(new Button("editEtage", "bearbeiten")); //bearbeiten Link $btnUpd = new Link($_SERVER['SCRIPT_NAME'] . "?" . "showUpdateMask" . $this->TABLENAME . "=" . $rowId, "bearbeiten"); $btnUpd->setValidate(false); //$div->add($btnUpd); // entfernen Link einfügen $frmDelBtn = new Form(); $frmDelBtn->add($this->DEFAULT_HIDDEN_FIELDS); $frmDelBtn->add(new Button("delete" . $rowId . $this->TABLENAME, "entfernen")); $rBtns = $tblBtns->createRow(); $rBtns->setAttribute(0, $frmUpdBtn); if ($this->isDeleteInUpdate()) { $rBtns->setAttribute(1, $frmDelBtn); } else { $rBtns->setSpawnAll(true); } $tblBtns->addRow($rBtns); $r->setAttribute(count($tNames) - 1, $tblBtns); $table->addRow($r); } $form = new Form($_SERVER['SCRIPT_NAME']); $form->add($this->getPageNavigation()); $form->add($table); $form->add($this->DEFAULT_HIDDEN_FIELDS); return $form; }
<? require_once("classes/Recipe.php"); ?> <? require_once("classes/Text.php"); ?> <? $cat = $_POST['cat']; if (strlen($cat) == 0) { $recipes = Recipe::getAll(); } else { if ($cat == "null") { $c = NULL; } else { $c = Category::getById($cat); if ($c == NULL) { $errMsg = Text::getText("CategoryNotFound").": ".$cat; include("error.php"); exit; } } $recipes = Recipe::getInCategory($c); } $categories = Category::getAll(); $catForId = array(); foreach ($categories as $tempCat) { $catForId[$tempCat->getId()] = $tempCat; } foreach ($recipes as $r) { $fieldName = "cat".$r->getId(); $newCatId = $_POST[$fieldName]; //print "recipe ".$r->getId().": $newCatId<br>"; if ($newCatId == "") {
<? require_once("classes/Recipe.php"); ?> <? require_once("classes/Text.php"); ?> <? $id = $_REQUEST['id']; if ($id == "") { $all = Recipe::getAll(); } else { $r = Recipe::getById($id); if ($r == NULL) { $errMsg = Text::getText("RecipeNotFound"); include("error.php"); exit; } $all = array(Recipe::getById($id)); } $hl = $_REQUEST['hl']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Steps</title> <link href="kupu/common/kupucontentstyles.css" rel="stylesheet" type="text/css" /> <link href="steps.css" rel="stylesheet" type="text/css" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" /> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> </head> <body> <?php
require_once "config.php"; require_once RESACCMAN_BASE . "/classes/Text.php"; require_once RESACCMAN_BASE . "/classes/html/GroupPermissionsForm.php"; $title = Text::getText("GroupPermissions"); if (GroupPermissionsForm::isSubmitted($_REQUEST)) { $g = GroupPermissionsForm::handle($_REQUEST); $today = date("r"); header("Location: groupPermissions.php?id=" . $g->getId() . "&saved=" . $today); } else { if (sizeof($_REQUEST['id']) > 0) { $g = SecurityGroup::getById($id); } } if ($g == NULL) { $errMsg = Text::getText("GroupNotFound") . ": '" . $id . "'"; die($errMsg); } $title .= ": " . $g->getName(); $form = new GroupPermissionsForm($g); if (strlen($_REQUEST['saved']) > 0) { $form->setMessage(IsatisText::getText("Saved") . ": " . $_REQUEST['saved']); } include "header.php"; ?> <h2><?php echo $title; ?> </h2><? $form->printContent(); include("footer.php");
</a> <? if (Recipe::havePermission("CHANGE")) { ?> <a href="editkupu.php?id=<?php echo $r->getId(); ?> "><?php echo Text::getText("Edit"); ?> </a> <? } ?> <? if (Recipe::havePermission("DELETE")) { ?> <a href="delete.php?id=<?php echo $r->getId(); ?> " onClick="return confirm('<?php echo Text::getText("ConfirmDelete"); ?> ')"><?php echo Text::getText("Delete"); ?> </a> <? } ?> </td> </tr> </table> </p> <? } ?> <? include("footer.php"); ?>
<?php require_once "config.php"; require_once RESACCMAN_BASE . "/classes/SecurityGroup.php"; require_once RESACCMAN_BASE . "/classes/Text.php"; require_once RESACCMAN_BASE . "/classes/html/GroupAddForm.php"; require_once RESACCMAN_BASE . "/classes/html/GroupList.php"; include "header.php"; ?> <h2><?php echo Text::getText("Groups"); ?> </h2><? $allGroups = SecurityGroup::getAll(); $list = new GroupList(); $list->setGroups($allGroups); $list->printContent(); if (SecurityGroup::havePermission("ADD")) { $form = new GroupAddForm(); $form->printContent(); } include("footer.php"); ?>