Хранилища Subversion ant

Сравнить редакции

Не учитывать пробелы Редакция 573 → Редакция 574

/branches/ant/0.9.x/lib/core.php
1069,6 → 1069,154
}
 
/**
* Вывод списка протоколов
*
* @author Alexander Wolf
* @category Core
*
* @param string $name
* @param string $actor
* @param string $format
* @return string
*/
public function showProtoList($name, $actor, $format = 'list') {
switch($format) {
case 'list':
$query = "SELECT * FROM ".$this->prefix."protos";
$rq =& $this->db->query($query);
$show = "<ul>\n";
while ($rq->fetchInto($element)) {
$show .= "<li>[<a href='".$actor."?mode=".$name."&action=edit&uuid=".$element["proto_id"]."' class='edit'>править</a>][<a href='".$actor."?mode=".$name."&action=delete&uuid=".$element["proto_id"]."' class='delete'>удалить</a>] ".$this->secure->checkStr($element["proto"],1)."</li>\n";
}
$show .= "</ul>";
break;
case 'innerhtml':
$protoID = $this->secure->checkInt($actor);
$query = "SELECT * FROM ".$this->prefix."protos";
$rq =& $this->db->query($query);
$show = "<select name='".$name."' id='".$name."'>\n";
while ($rq->fetchInto($element)) {
if ($element["proto_id"]==$protoID) {
$show .= "<option value='".$this->secure->checkInt($element["proto_id"])."' selected>".$this->secure->checkStr($element["proto"],1)."</option>\n";
} else {
$show .= "<option value='".$this->secure->checkInt($element["proto_id"])."'>".$this->secure->checkStr($element["scheme"],1)."</option>\n";
}
}
$show .= "</select>";
break;
}
return $show;
}
 
/**
* Добавление нового протокола
*
* @author Alexander Wolf
* @category Core
*
* @param string $proto
* @return array
*/
public function addProto($proto) {
$result = array();
$sProto = $this->secure->checkStr($proto,1);
 
$query = "INSERT INTO ".$this->prefix."protos SET proto='".$sProto."'";
$rq =& $this->db->query($query);
if (PEAR::isError($this->db)) {
$result["ERR"] = 1;
$result["ERRINFO"] = $this->db->getMessage();
} else {
$result["ERR"] = 0;
}
 
return $result;
}
 
/**
* Удаление информации о протоколе
*
* @author Alexander Wolf
* @category Core
*
* @param integer $protoID
* @return array
*/
public function dropProto($protoID) {
$result = array();
$sProtoID = $this->secure->checkInt($protoID);
 
// Удаление протокола
$query = "DELETE FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'";
$rq =& $this->db->query($query);
if (PEAR::isError($this->db)) {
$result["ERR"] = 1;
$result["ERRINFO"] = $this->db->getMessage();
} else {
$result["ERR"] = 0;
}
 
return $result;
}
 
/**
* Обновление информации о протоколе
*
* @author Alexander Wolf
* @category Core
*
* @param integer $protoID
* @param string $info
* @return array
*/
public function updateProto($protoID, $info) {
$result = array();
$sProtoID = $this->secure->checkInt($protoID);
$sProto = $this->secure->checkStr($proto,1);
 
$query = "UPDATE ".$this->prefix."protos SET proto='".$sProto."' WHERE proto_id='".$sProtoID."'";
$rq =& $this->db->query($query);
if (PEAR::isError($this->db)) {
$result["ERR"] = 1;
$result["ERRINFO"] = $this->db->getMessage();
} else {
$result["ERR"] = 0;
}
 
return $result;
}
 
/**
* Вывод формы редактирования/добавления протоколов
*
* @author Alexander Wolf
* @category Core
*
* @param integer $protoID
* @param string $info
* @return string
*/
public function showProtoForm($protoID = 0, $info = "") {
$sProtoID = $this->secure->checkInt($protoID);
$sInfo = $this->secure->checkStr($info, 1);
if ($sInfo == "") {
$sInfo = "Протокол доступа";
}
$show = "<fieldset><legend>".$sInfo."</legend>\n";
if ($sProtoID != 0) {
// Режим редактирования
$query = "SELECT * FROM ".$this->prefix."protos WHERE proto_id='".$sProtoID."'";
$rq =& $this->db->query($query);
$rq->fetchInto($element);
}
 
$show .= "<div class='inputbox'><label for='proto'>Протокол доступа:</label> <input type='text' name='proto' id='proto' value='".$this->secure->checkStr($element["proto"],1)."'></div>\n";
$show .= "<div class='inputbox'><input type='submit' value=' Отправить данные '></div>\n</fieldset>\n";
 
return $show;
}
 
/**
* Показывает список подписей
*
* @author Alexander Wolf