p($info['name']); ?> </strong> <div class="right"><a href="?page=contact&id=<?php p($contact->getId()); ?> ">Edit</a> - <a href="?page=contact-delete&id=<?php p($contact->getId()); ?> ">Delete</a></div> </div> <ul class="information"> <?php foreach ($info['channels'] as $chan) { $chandle = Channel::fetch(intval($chan['id'])); ?> <li> <?php p($chandle->getName()); ?> <div class="descr"><?php p($chandle); ?> </div> </li> <?php } ?> </ul> <?php
public function processAddEdit($data) { $errors = array(); if (strlen($data['hostname']) == 0) { $errors['hostname'] = 'Hostname cannot be blank.'; } $this->hostname = $data['hostname']; if (!is_numeric($data['port'])) { $errors['port'] = 'Port must be numeric.'; } $this->port = intval($data['port']); $this->alias = $data['alias']; if (!is_numeric($data['fail_threshold']) || intval($data['fail_threshold']) <= 0) { $errors['fail_threshold'] = 'Failure threshold must be a positive integer.'; } $this->fail_threshold = intval($data['fail_threshold']); $this->notification_channels = array(); if (is_array($data['notification_channels'])) { foreach ($data['notification_channels'] as $id) { $this->notification_channels[] = Channel::fetch(intval($id)); } } $this->status = intval($data['status']); if ($this->status == STATUS_DOWNTIME) { if (!is_numeric($data['downtime_start_hours']) || !is_numeric($data['downtime_start_minutes']) || !is_numeric($data['downtime_end_hours']) || !is_numeric($data['downtime_end_minutes'])) { $errors['interval'] = 'Invalid time or interval.'; } $this->downtime_start = time() + intval($data['downtime_start_hours']) * 60 + intval($data['downtime_start_minutes']); $this->downtime_end = time() + intval($data['downtime_end_hours']) * 60 + intval($data['downtime_end_minutes']); } else { $this->downtime_start = 0; $this->downtime_end = 0; } $errors = $this->customProcessAddEdit($data, $errors); return $errors; }
<?php $channel = Channel::fetch(intval($_GET['id'])); $owner = $channel->getOwner(); if (FormHelpers::donePOST()) { $channel->processDelete($_GET); ?> <div class="message"> The channel has been deleted. <br /> <a href="?page=contact&id=<?php p($owner); ?> ">Return to contact</a> </div> <?php } else { ?> <div class="form-field"> </div> <?php FormHelpers::startForm('POST', '?page=channel-delete&id=' . $channel->getId()); FormHelpers::createHidden('confirmed', '1'); ?> <center> Are you sure you want to delete this channel?<br /> <?php FormHelpers::createSubmit('Yes'); ?> </center> <?php FormHelpers::endForm();
public function processDelete($data) { $chans = $GLOBALS['PW_DB']->executeSelect('id', 'channels', 'WHERE owner=' . intval($data['id'])); foreach ($chans as $chan) { $channel = Channel::fetch($chan); $channel->processDelete(); } $GLOBALS['PW_DB']->executeDelete('contacts', 'WHERE id=' . intval($data['id'])); }