Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
04b88d4344
3 changed files with 50 additions and 29 deletions
|
@ -2,9 +2,12 @@
|
||||||
|
|
||||||
class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
||||||
{
|
{
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
|
// retrieves the length limit for each char field
|
||||||
|
// and store to assoc array
|
||||||
|
$maxLens = Application_Model_Show::GetMaxLengths();
|
||||||
|
|
||||||
// Hidden element to indicate whether the show is new or
|
// Hidden element to indicate whether the show is new or
|
||||||
// whether we are updating an existing show.
|
// whether we are updating an existing show.
|
||||||
$this->addElement('hidden', 'add_show_id', array(
|
$this->addElement('hidden', 'add_show_id', array(
|
||||||
|
@ -18,7 +21,8 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'filters' => array('StringTrim'),
|
'filters' => array('StringTrim'),
|
||||||
'validators' => array('NotEmpty'),
|
'validators' => array('NotEmpty'),
|
||||||
'value' => 'Untitled Show'
|
'value' => 'Untitled Show',
|
||||||
|
'validators' => array(array('StringLength', false, array(0, $maxLens['name'])))
|
||||||
));
|
));
|
||||||
|
|
||||||
// Add URL element
|
// Add URL element
|
||||||
|
@ -27,7 +31,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
||||||
'class' => 'input_text',
|
'class' => 'input_text',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'filters' => array('StringTrim'),
|
'filters' => array('StringTrim'),
|
||||||
'validators' => array('NotEmpty')
|
'validators' => array('NotEmpty', array('StringLength', false, array(0, $maxLens['url'])))
|
||||||
));
|
));
|
||||||
|
|
||||||
// Add genre element
|
// Add genre element
|
||||||
|
@ -35,14 +39,16 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
||||||
'label' => 'Genre:',
|
'label' => 'Genre:',
|
||||||
'class' => 'input_text',
|
'class' => 'input_text',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'filters' => array('StringTrim')
|
'filters' => array('StringTrim'),
|
||||||
|
'validators' => array(array('StringLength', false, array(0, $maxLens['genre'])))
|
||||||
));
|
));
|
||||||
|
|
||||||
// Add the description element
|
// Add the description element
|
||||||
$this->addElement('textarea', 'add_show_description', array(
|
$this->addElement('textarea', 'add_show_description', array(
|
||||||
'label' => 'Description:',
|
'label' => 'Description:',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'class' => 'input_text_area'
|
'class' => 'input_text_area',
|
||||||
|
'validators' => array(array('StringLength', false, array(0, $maxLens['description'])))
|
||||||
));
|
));
|
||||||
|
|
||||||
$descText = $this->getElement('add_show_description');
|
$descText = $this->getElement('add_show_description');
|
||||||
|
@ -53,7 +59,5 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
|
||||||
))));
|
))));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,30 +29,32 @@ class Application_Model_Preference
|
||||||
|
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
if ($result == 1 && is_null($id)){
|
if($result == 1) {
|
||||||
$sql = "UPDATE cc_pref"
|
// result found
|
||||||
." SET subjid = NULL, valstr = '$value'"
|
if(is_null($id) || !$isUserValue) {
|
||||||
." WHERE keystr = '$key'";
|
// system pref
|
||||||
}
|
$sql = "UPDATE cc_pref"
|
||||||
else if ($result == 1 && !is_null($id)){
|
." SET subjid = NULL, valstr = '$value'"
|
||||||
if($isUserValue) {
|
|
||||||
$sql = "UPDATE cc_pref"
|
|
||||||
." SET valstr = '$value'"
|
|
||||||
." WHERE keystr = '$key' AND subjid = $id";
|
|
||||||
} else {
|
|
||||||
$sql = "UPDATE cc_pref"
|
|
||||||
." SET subjid = $id, valstr = '$value'"
|
|
||||||
." WHERE keystr = '$key'";
|
." WHERE keystr = '$key'";
|
||||||
}
|
} else {
|
||||||
}
|
// user pref
|
||||||
else if(is_null($id)) {
|
$sql = "UPDATE cc_pref"
|
||||||
$sql = "INSERT INTO cc_pref (keystr, valstr)"
|
. " SET valstr = '$value'"
|
||||||
." VALUES ('$key', '$value')";
|
. " WHERE keystr = '$key' AND subjid = $id";
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
// result not found
|
||||||
." VALUES ($id, '$key', '$value')";
|
if(is_null($id) || !$isUserValue) {
|
||||||
|
// system pref
|
||||||
|
$sql = "INSERT INTO cc_pref (keystr, valstr)"
|
||||||
|
." VALUES ('$key', '$value')";
|
||||||
|
} else {
|
||||||
|
// user pref
|
||||||
|
$sql = "INSERT INTO cc_pref (subjid, keystr, valstr)"
|
||||||
|
." VALUES ($id, '$key', '$value')";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $CC_DBC->query($sql);
|
return $CC_DBC->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1358,4 +1358,19 @@ class Application_Model_Show {
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
return $CC_DBC->GetAll($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function GetMaxLengths() {
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
$sql = "SELECT column_name, character_maximum_length FROM information_schema.columns"
|
||||||
|
." WHERE table_name = 'cc_show' AND character_maximum_length > 0";
|
||||||
|
$result = $CC_DBC->GetAll($sql);
|
||||||
|
|
||||||
|
// store result into assoc array
|
||||||
|
$assocArray = array();
|
||||||
|
foreach($result as $row) {
|
||||||
|
$assocArray[$row['column_name']] = $row['character_maximum_length'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $assocArray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue