}
}
}
+ return $this->id;
}
/**
* by given DB table id load all the info we need
* @param int $id
- * @return boolean
+ * @return mixed
*/
public function initbyid($id) {
- $ret = false;
+ $this->id = false;
if(!empty($id)) {
$queryStr = "SELECT id,name
if(!empty($query) && $query->num_rows > 0) {
$result = $query->fetch_assoc();
$this->id = $id;
- $ret = true;
}
}
- return $ret;
+ return $this->id;
}
/**
$query = $this->DB->query($queryStr);
if(!empty($query)) {
while($result = $query->fetch_assoc()) {
- if($stats === true) {
+ if($stats === true && isset($statsInfo[$result['id']])) {
$ret[$result['id']] = array('name' => $result['name'], 'amount' => $statsInfo[$result['id']]);
}
else {
--- /dev/null
+<?php
+if(!empty($submitFeedback)) {
+ $cssClass="is-success";
+ if($submitFeedback['status'] == "error") {
+ $cssClass="is-danger";
+ }
+ $message = $submitFeedback['message'];
+ if(is_array($message)) {
+ $message = implode("<br />", $message);
+ }
+?>
+ <div class="columns">
+ <div class="column">
+ <div class="notification <?php echo $cssClass; ?>">
+ <p><?php echo $message; ?></p>
+ </div>
+ </div>
+ </div>
+<?php } ?>
# first deletion, then update and then add
# adding a new one which matches an existing one will update it.
+ $submitFeedback['message'] = array();
+ $submitFeedback['status'] = 'success';
+
if(!empty($deleteCategoryData)) {
+ $submitFeedback['message'][] = 'Categories deleted successfully.';
+
foreach($deleteCategoryData as $k=>$v) {
if($v == "delete") {
$catObj = new Category($DB);
$load = $catObj->initbyid($k);
- if($load === true) {
+ if($load !== false) {
$catObj->delete();
}
+ else {
+ $submitFeedback['message'][] = 'Categories could not be deleted.';
+ $submitFeedback['status'] = 'error';
+ }
}
}
-
- $submitFeedback['message'] = 'Link updated successfully.';
- $submitFeedback['status'] = 'success';
}
- $submitFeedback['message'] = 'Something went wrong...';
- $submitFeedback['status'] = 'error';
+ if(!empty($newCategory)) {
+ $submitFeedback['message'][] = 'Categories added successfully.';
+ $catArr = Summoner::prepareTagOrCategoryStr($newCategory);
+
+ foreach($catArr as $c) {
+ $catObj = new Category($DB);
+ $do = $catObj->initbystring($c);
+ if($do === false) {
+ $submitFeedback['message'][] = 'Category could not be added.';
+ $submitFeedback['status'] = 'error';
+ }
+ }
+ }
}
# show all the categories we have
<?php } ?>
</div>
</div>
+
+<?php require('_displaySubmitStatus.inc.php'); ?>
+
</section>
<section>
</div>
</div>
<?php } ?>
-<?php if(!empty($submitFeedback)) { ?>
- <div class="columns">
- <div class="column">
-<?php if($submitFeedback['status'] == "error") { ?>
- <div class="notification is-danger">
- <h5>Error</h5>
- <p><?php echo $submitFeedback['message']; ?></p>
- </div>
-<?php } else { ?>
- <div class="notification is-success">
- <h5>Success</h5>
- <p><?php echo $submitFeedback['message']; ?></p>
- </div>
-<?php } ?>
- </div>
- </div>
-<?php } ?>
+
+<?php require('_displaySubmitStatus.inc.php'); ?>
<div class="columns">
<div class="column">
</p>
</div>
- </div>
-</section>
+<?php require('_displaySubmitStatus.inc.php'); ?>
-<?php if(!empty($submitFeedback)) { ?>
-<section class="section">
-<div class="columns">
- <div class="column">
-<?php if($submitFeedback['status'] == "error") { ?>
- <div class="notification is-danger">
- <?php echo $submitFeedback['message']; ?>
- </div>
-<?php } else { ?>
- <div class="notification is-success">
- <p><?php echo $submitFeedback['message']; ?></p>
- </div>
-<?php } ?>
</div>
-</div>
</section>
-<?php } ?>
<?php if(!empty($searchResult)) { ?>
<section class="section">