public function processEditSingleItemAction()
 {
     $field = $this->_getParam("field");
     $enumerationId = (int) $this->_getParam("enumerationId");
     $value = preg_replace('/[^a-z_0-9- ]/i', '', $this->_getParam("value", ""));
     $enumeration = new Enumeration();
     $data = '';
     if ($enumerationId > 0 && in_array($field, $enumeration->ormFields())) {
         $enumeration->enumerationId = $enumerationId;
         $enumeration->populate();
         $enumeration->{$field} = $value;
         $enumeration->persist();
         $enum = new Enumeration();
         $enum->enumerationId = $enumerationId;
         $enum->populate();
         $data = $enum->{$field};
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
 public function insertEnumeration($data, $parentId = 0)
 {
     $db = Zend_Registry::get("dbAdapter");
     $enumParent = new Enumeration();
     $enumParent->enumerationId = $parentId;
     $enumParent->populate();
     $enumeration = new Enumeration();
     $fields = $enumeration->ormFields();
     foreach ($data as $key => $value) {
         if (!in_array($key, $fields)) {
             continue;
         }
         $enumeration->{$key} = $value;
     }
     if (!strlen($enumeration->ormClass) > 0) {
         // check if parent item has an ormClass and id defined and use that to its child
         if (strlen($enumParent->ormClass) > 0) {
             $enumeration->ormClass = $enumParent->ormClass;
             // we only need to use the parent ormId if child's ormId less than or equal to 0
             if ($enumeration->ormId <= 0) {
                 // temporarily comment out
                 //$enumeration->ormId = $enumParent->ormId;
             }
         }
     }
     // we only need to use the parent ormEditMethod if child's ormEditMethod not defined
     if (!strlen($enumeration->ormEditMethod) > 0) {
         $enumeration->ormEditMethod = $enumParent->ormEditMethod;
     }
     $enumeration->persist();
     $enumerationId = $enumeration->enumerationId;
     $sql = "INSERT INTO enumerationsClosure (ancestor,descendant,depth)\n\t\t\t  SELECT ancestor,{$enumerationId},depth+1 FROM enumerationsClosure\n\t\t\t  WHERE descendant = {$parentId}\n\t\t\t  UNION ALL\n\t\t\t  SELECT {$enumerationId},{$enumerationId},0";
     $db->query($sql);
     return $enumerationId;
 }