Skip to content
Permalink
Browse files

Reintroduce the is_int but typecast the enum fields into strings.

git-svn-id: https://svn.code.sf.net/p/freeghost/code/trunk@5517 71f96598-fa45-0410-b640-bcd6f8691b32
  • Loading branch information...
mastacontrola committed May 21, 2016
1 parent 021fbf1 commit c0cc632d0e27da284fd4a6a9796ee7088e14050b
@@ -177,6 +177,9 @@ private static function prepare() {
private static function bind($param, $value, $type = null) {
if (is_null($type)) {
switch (true) {
case is_int($value):
$type = PDO::PARAM_INT;
break;
case is_bool($value):
$type = PDO::PARAM_BOOL;
break;
@@ -416,7 +416,7 @@ public function deploy_post() {
$scheduleDeployTime = self::nice_date($_REQUEST['scheduleSingleTime']);
$imagingTasks = in_array($TaskType->get('id'),array(1,2,8,15,16,17,24));
$passreset = trim($_REQUEST['account']);
$wol = (int)(isset($_REQUEST['wol']) || $TaskType->get('id') == 14);
$wol = (string)(isset($_REQUEST['wol']) || $TaskType->get('id') == 14);
try {
if (!$TaskType || !$TaskType->isValid()) throw new Exception(_('Task type is not valid'));
$taskName = sprintf('%s Task',$TaskType->get('name'));
@@ -588,8 +588,7 @@ public function basictasksOptions() {
$this->render();
unset($this->data);
printf('<div id="advanced-tasks" class="hidden"><h2>%s</h2>',_('Advanced Actions'));
$TaskTypes = self::getClass('TaskTypeManager')->find(array('access'=>array('both',$this->node),'isAdvanced'=>1),'AND','id');
foreach(self::getClass('TaskTypeManager')->find(array('access'=>array('both',$this->node),'isAdvanced'=>1),'AND','id') AS $i => &$TaskType) {
foreach(self::getClass('TaskTypeManager')->find(array('access'=>array('both',$this->node),'isAdvanced'=>1),'AND','id') AS &$TaskType) {
if (!$TaskType->isValid()) continue;
$this->data[] = array(
'node'=>$this->node,
@@ -462,7 +462,7 @@ private function createTasking($taskName, $taskTypeID, $username, $groupID, $mem
->set('typeID',$taskTypeID)
->set('NFSGroupID',$groupID)
->set('NFSMemberID',$memID)
->set('wol',(int)$wol);
->set('wol',(string)$wol);
if ($imagingTask) $Task->set('imageID',$this->getImage()->get('id'));
if ($shutdown) $Task->set('shutdown',$shutdown);
if ($debug) $Task->set('isDebug',$debug);
@@ -760,7 +760,7 @@ public function setAD($useAD = '',$domain = '',$ou = '',$user = '',$pass = '',$o
if (empty($pass)) $pass = trim($this->encryptpw($this->get('ADPass')));
if (empty($legacy)) $legacy = trim($this->get('ADPassLegacy'));
if (empty($productKey)) $productKey = trim($this->encryptpw($this->get('productKey')));
if (empty($enforce)) $enforce = (int)$this->get('enforce');
if (empty($enforce)) $enforce = (string)$this->get('enforce');
}
}
if ($pass) $pass = trim($this->encryptpw($pass));
@@ -1,7 +1,7 @@
<?php
class System {
public function __construct() {
define('FOG_VERSION', '7743');
define('FOG_VERSION', '7745');
define('FOG_SCHEMA', 218);
define('FOG_BCACHE_VER',58);
define('FOG_SVN_REVISION', '$Revision: 2868 $');
@@ -188,7 +188,7 @@ public function add_post() {
$passlegacy = trim($_REQUEST['domainpasswordlegacy']);
$productKey = preg_replace('/([\w+]{5})/','$1-',str_replace('-','',strtoupper(trim($_REQUEST['key']))));
$productKey = substr($productKey,0,29);
$enforce = (int)isset($_REQUEST['enforcesel']);
$enforce = (string)isset($_REQUEST['enforcesel']);
$Host = self::getClass('Host')
->set('name',$hostName)
->set('description',$_REQUEST['description'])
@@ -768,7 +768,7 @@ public function edit_post() {
$user = trim($_REQUEST['domainuser']);
$pass = trim($_REQUEST['domainpassword']);
$passlegacy = trim($_REQUEST['domainpasswordlegacy']);
$enforce = (int)isset($_REQUEST['enforcesel']);
$enforce = (string)isset($_REQUEST['enforcesel']);
$this->obj->setAD($useAD,$domain,$ou,$user,$pass,true,true,$passlegacy,$productKey,$enforce);
break;
case 'host-printers':
@@ -167,8 +167,8 @@ public function add_post() {
->set('imageTypeID',$_REQUEST['imagetype'])
->set('imagePartitionTypeID',$_REQUEST['imagepartitiontype'])
->set('compress',$_REQUEST['compress'])
->set('isEnabled',(int) isset($_REQUEST['isEnabled']))
->set('toReplicate',(int) isset($_REQUEST['toReplicate']))
->set('isEnabled',(string)isset($_REQUEST['isEnabled']))
->set('toReplicate',(string)isset($_REQUEST['toReplicate']))
->addGroup($_REQUEST['storagegroup']);
if (!$Image->save()) throw new Exception(_('Database update failed'));
self::$HookManager->processEvent('IMAGE_ADD_SUCCESS',array('Image'=>&$Image));
@@ -300,8 +300,8 @@ public function edit_post() {
->set('format',isset($_REQUEST['imagemanage']) ? $_REQUEST['imagemanage'] : $this->obj->get('format'))
->set('protected',(int)isset($_REQUEST['protected_image']))
->set('compress',$_REQUEST['compress'])
->set('isEnabled',(int) isset($_REQUEST['isEnabled']))
->set('toReplicate',(int) isset($_REQUEST['toReplicate']));
->set('isEnabled',(string)isset($_REQUEST['isEnabled']))
->set('toReplicate',(string)isset($_REQUEST['toReplicate']));
break;
case 'image-storage':
$this->obj->addGroup($_REQUEST['storagegroup']);
@@ -172,11 +172,11 @@ public function add_post() {
->set('file',$snapinfile)
->set('args',$_REQUEST['args'])
->set('reboot',(int)(isset($_REQUEST['action']) && $_REQUEST['action'] === 'reboot'))
->set('shutdown',(int)(isset($_REQUEST['action']) && $_REQUEST['action'] === 'shutdown'))
->set('shutdown',(string)(isset($_REQUEST['action']) && $_REQUEST['action'] === 'shutdown'))
->set('runWith',$_REQUEST['rw'])
->set('runWithArgs',$_REQUEST['rwa'])
->set('isEnabled',(int)isset($_REQUEST['isEnabled']))
->set('toReplicate',(int)isset($_REQUEST['toReplicate']))
->set('isEnabled',(string)isset($_REQUEST['isEnabled']))
->set('toReplicate',(string)isset($_REQUEST['toReplicate']))
->addGroup($_REQUEST['storagegroup']);
if (!$Snapin->save()) throw new Exception(_('Add snapin failed!'));
self::$HookManager->processEvent('SNAPIN_ADD_SUCCESS',array('Snapin'=>&$Snapin));
@@ -344,12 +344,12 @@ public function edit_post() {
->set('file',$snapinfile)
->set('args',$_REQUEST['args'])
->set('reboot',(int)(isset($_REQUEST['action']) && $_REQUEST['action'] === 'reboot'))
->set('shutdown',(int)(isset($_REQUEST['action']) && $_REQUEST['action'] === 'shutdown'))
->set('shutdown',(string)(isset($_REQUEST['action']) && $_REQUEST['action'] === 'shutdown'))
->set('runWith',$_REQUEST['rw'])
->set('runWithArgs',$_REQUEST['rwa'])
->set('protected',(int)isset($_REQUEST['protected_snapin']))
->set('isEnabled',(int)isset($_REQUEST['isEnabled']))
->set('toReplicate',(int)isset($_REQUEST['toReplicate']));
->set('isEnabled',(string)isset($_REQUEST['isEnabled']))
->set('toReplicate',(string)isset($_REQUEST['toReplicate']));
break;
case 'snap-storage':
$this->obj->addGroup($_REQUEST['storagegroup']);
@@ -131,7 +131,7 @@ public function add_storage_node() {
_('Bitrate') => '<input type="text" name="bitrate" value="${node_bitrate}" autocomplete="off" />',
self::$foglang['Interface'] => '<input type="text" name="interface" value="${node_interface}" autocomplete="off" />',
self::$foglang['IsEnabled'] => '<input type="checkbox" name="isEnabled" checked value="1" />',
self::$foglang['IsGraphEnabled'].'<br /><small>('.self::$foglang[OnDash].')' => '<input type="checkbox" name="isGraphEnabled" checked value="1" />',
self::$foglang['IsGraphEnabled'].'<br /><small>('.self::$foglang['OnDash'].')' => '<input type="checkbox" name="isGraphEnabled" checked value="1" />',
self::$foglang['ManUser'] => '<input type="text" name="user" value="${node_user}" autocomplete="off" />*',
self::$foglang['ManPass'] => '<input type="password" name="pass" value="${node_pass}" autocomplete="off" />*',
'<input type="hidden" name="add" value="1" />' => '<input type="submit" value="'.self::$foglang['Add'].'" autocomplete="off" />',
@@ -190,7 +190,7 @@ public function add_storage_node_post() {
->set('sslpath',$_REQUEST['sslpath'])
->set('bitrate', $_REQUEST['bitrate'])
->set('interface',$_REQUEST['interface'])
->set('isGraphEnabled',(int)isset($_REQUEST['isGraphEnabled']))
->set('isGraphEnabled',(string)isset($_REQUEST['isGraphEnabled']))
->set('isEnabled',(int)isset($_REQUEST['isEnabled']))
->set('user',$_REQUEST['user'])
->set('pass',$_REQUEST['pass'])
@@ -296,7 +296,7 @@ public function edit_storage_node_post() {
->set('sslpath',$_REQUEST['sslpath'])
->set('bitrate',$_REQUEST['bitrate'])
->set('interface',$_REQUEST['interface'])
->set('isGraphEnabled',(int)isset($_REQUEST['isGraphEnabled']))
->set('isGraphEnabled',(string)isset($_REQUEST['isGraphEnabled']))
->set('isEnabled',(int)isset($_REQUEST['isEnabled']))
->set('user',$_REQUEST['user'])
->set('pass',$_REQUEST['pass'])
@@ -422,27 +422,27 @@ public function add_storage_group() {
}
public function add_storage_group_post() {
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_ADD_POST);
self::$HookManager->processEvent('STORAGE_GROUP_ADD_POST');
// POST
try {
// Error checking
if (empty($_REQUEST[name])) throw new Exception(self::$foglang[SGNameReq]);
if (self::getClass(StorageGroupManager)->exists($_REQUEST[name])) throw new Exception(self::$foglang[SGExist]);
if (empty($_REQUEST['name'])) throw new Exception(self::$foglang['SGNameReq']);
if (self::getClass('StorageGroupManager')->exists($_REQUEST['name'])) throw new Exception(self::$foglang['SGExist']);
// Create new Object
$StorageGroup = self::getClass(StorageGroup)
->set(name,$_REQUEST[name])
->set(description,$_REQUEST[description]);
$StorageGroup = self::getClass('StorageGroup')
->set('name',$_REQUEST['name'])
->set('description',$_REQUEST['description']);
// Save
if (!$StorageGroup->save()) throw new Exception(self::$foglang[DBupfailed]);
if (!$StorageGroup->save()) throw new Exception(self::$foglang['DBupfailed']);
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_ADD_POST_SUCCESS,array(StorageGroup=>&$StorageGroup));
self::$HookManager->processEvent('STORAGE_GROUP_ADD_POST_SUCCESS',array(StorageGroup=>&$StorageGroup));
// Set session message
$this->setMessage(self::$foglang[SGCreated]);
$this->setMessage(self::$foglang['SGCreated']);
// Redirect to new entry
$this->redirect(sprintf('?node=%s&sub=edit-storage-group&%s=%s',$_REQUEST[node],$this->id,$StorageGroup->get(id)));
$this->redirect(sprintf('?node=%s&sub=edit-storage-group&%s=%s',$_REQUEST['node'],$this->id,$StorageGroup->get('id')));
} catch (Exception $e) {
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_ADD_POST_FAIL, array(StorageGroup=>&$StorageGroup));
self::$HookManager->processEvent('STORAGE_GROUP_ADD_POST_FAIL', array('StorageGroup'=>&$StorageGroup));
// Set session message
$this->setMessage($e->getMessage());
// Redirect to new entry
@@ -466,47 +466,47 @@ public function edit_storage_group() {
);
// Fields
$fields = array(
self::$foglang[SGName]=>'<input type="text" name="name" value="'.$this->obj->get(name).'" />',
self::$foglang[SGDesc]=>'<textarea name="description" rows="8" cols="40">'.$this->obj->get(description).'</textarea>',
'&nbsp;'=>'<input type="submit" value="'.self::$foglang[Update].'" />',
self::$foglang['SGName']=>'<input type="text" name="name" value="'.$this->obj->get('name').'" />',
self::$foglang['SGDesc']=>'<textarea name="description" rows="8" cols="40">'.$this->obj->get('description').'</textarea>',
'&nbsp;'=>'<input type="submit" value="'.self::$foglang['Update'].'" />',
);
echo '<form method="post" action="'.$this->formAction.'">';
foreach((array)$fields AS $field => &$input) {
$this->data[] = array(
field=>$field,
input=>$input,
'field'=>$field,
'input'=>$input,
);
}
unset($input);
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_EDIT,array(headerData=>&$this->headerData,data=>&$this->data,templates=>&$this->templates,attributes=>&$this->attributes));
self::$HookManager->processEvent('STORAGE_GROUP_EDIT',array('headerData'=>&$this->headerData,'data'=>&$this->data,'templates'=>&$this->templates,'attributes'=>&$this->attributes));
// Output
$this->render();
echo '</form>';
}
public function edit_storage_group_post() {
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_EDIT_POST,array(StorageGroup=>&$this->obj));
self::$HookManager->processEvent('STORAGE_GROUP_EDIT_POST',array('StorageGroup'=>&$this->obj));
// POST
try {
// Error checking
if (empty($_REQUEST[name])) throw new Exception(self::$foglang[SGName]);
if ($this->obj->get(name) != $_REQUEST[name] && self::getClass(StorageGroupManager)->exists($_REQUEST[name], $this->obj->get(id))) throw new Exception(self::$foglang[SGExist]);
if (empty($_REQUEST['name'])) throw new Exception(self::$foglang['SGName']);
if ($this->obj->get('name') != $_REQUEST['name'] && self::getClass('StorageGroupManager')->exists($_REQUEST['name'], $this->obj->get('id'))) throw new Exception(self::$foglang['SGExist']);
// Update Object
$this->obj
->set(name,$_REQUEST[name])
->set(description,$_REQUEST[description]);
->set('name',$_REQUEST['name'])
->set('description',$_REQUEST['description']);
// Save
if (!$this->obj->save()) throw new Exception(self::$foglang[DBupfailed]);
if (!$this->obj->save()) throw new Exception(self::$foglang['DBupfailed']);
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_EDIT_POST_SUCCESS,array(StorageGroup=>&$this->obj));
self::$HookManager->processEvent('STORAGE_GROUP_EDIT_POST_SUCCESS',array('StorageGroup'=>&$this->obj));
// Set session message
$this->setMessage(self::$foglang[SGUpdated]);
$this->setMessage(self::$foglang['SGUpdated']);
// Redirect to new entry
$this->redirect(sprintf('?node=%s&sub=storage-group', $_REQUEST[node],$this->id,$this->obj->get(id)));
$this->redirect(sprintf('?node=%s&sub=storage-group', $_REQUEST['node'],$this->id,$this->obj->get('id')));
} catch (Exception $e) {
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_EDIT_FAIL,array(StorageGroup=>&$this->obj));
self::$HookManager->processEvent('STORAGE_GROUP_EDIT_FAIL',array('StorageGroup'=>&$this->obj));
// Set session message
$this->setMessage($e->getMessage());
// Redirect to new entry
@@ -515,7 +515,7 @@ public function edit_storage_group_post() {
}
public function delete_storage_group() {
// Title
$this->title = sprintf('%s: %s',self::$foglang[Remove],$this->obj->get(name));
$this->title = sprintf('%s: %s',self::$foglang['Remove'],$this->obj->get('name'));
// Headerdata
unset($this->headerData);
// Attributes
@@ -529,40 +529,40 @@ public function delete_storage_group() {
'${input}',
);
$fields = array(
self::$foglang[ConfirmDel].' <b>'.$this->obj->get(name).'</b>' => '<input type="submit" value="'.$this->title.'" />',
self::$foglang['ConfirmDel'].' <b>'.$this->obj->get('name').'</b>' => '<input type="submit" value="'.$this->title.'" />',
);
foreach((array)$fields AS $field => &$input) {
$this->data[] = array(
field=>$field,
input=>$input,
'field'=>$field,
'input'=>$input,
);
}
unset($input);
echo '<form method="post" action="'.$this->formAction.'" class="c">';
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_DELETE,array(headerData=>&$this->headerData,data=>&$this->data,templates=>&$this->templates,attributes=>&$this->attributes));
self::$HookManager->processEvent('STORAGE_GROUP_DELETE',array('headerData'=>&$this->headerData,'data'=>&$this->data,'templates'=>&$this->templates,'attributes'=>&$this->attributes));
// Output
$this->render();
echo '</form>';
}
public function delete_storage_group_post() {
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_DELETE_POST,array(StorageGroup=>&$this->obj));
self::$HookManager->processEvent('STORAGE_GROUP_DELETE_POST',array('StorageGroup'=>&$this->obj));
// POST
try {
// Error checking
if (self::getClass(StorageGroupManager)->count() == 1) throw new Exception(self::$foglang[OneSG]);
if (self::getClass('StorageGroupManager')->count() == 1) throw new Exception(self::$foglang['OneSG']);
// Destroy
if (!$this->obj->destroy()) throw new Exception(self::$foglang[FailDelSG]);
if (!$this->obj->destroy()) throw new Exception(self::$foglang['FailDelSG']);
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_DELETE_POST_SUCCESS, array(StorageGroup=>&$this->obj));
self::$HookManager->processEvent('STORAGE_GROUP_DELETE_POST_SUCCESS', array('StorageGroup'=>&$this->obj));
// Set session message
$this->setMessage(sprintf('%s: %s',self::$foglang[SGDelSuccess],$this->obj->get(name)));
$this->setMessage(sprintf('%s: %s',self::$foglang['SGDelSuccess'],$this->obj->get('name')));
// Redirect
$this->redirect(sprintf('?node=%s&sub=storage-group', $_REQUEST[node]));
$this->redirect(sprintf('?node=%s&sub=storage-group', $_REQUEST['node']));
} catch (Exception $e) {
// Hook
self::$HookManager->processEvent(STORAGE_GROUP_DELETE_POST_FAIL,array(StorageGroup=>&$this->obj));
self::$HookManager->processEvent('STORAGE_GROUP_DELETE_POST_FAIL',array('StorageGroup'=>&$this->obj));
// Set session message
$this->setMessage($e->getMessage());
// Redirect

0 comments on commit c0cc632

Please sign in to comment.
You can’t perform that action at this time.