function getByScriptNameAndStatus($script_name, $status, $where = NULL, $order = NULL) { if ($script_name == '') { return FALSE; } if ($status == '') { return FALSE; } $status_key = Option::getByValue($status, $this->getOptions('status')); if ($status_key !== FALSE) { $status = $status_key; } $hgcf = new HelpGroupControlFactory(); $hg = new HelpGroupFactory(); $ph = array('script_name' => $script_name, 'status_id' => $status); $query = ' select a.*, b.name as group_name from ' . $this->getTable() . ' as a, ' . $hgcf->getTable() . ' as b, ' . $hg->getTable() . ' as c where b.id = c.help_group_control_id AND c.help_id = a.id AND b.script_name = ? AND a.status_id = ? AND a.deleted=0 AND b.deleted=0 ORDER BY a.type_id desc, c.order_value asc '; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order); $this->ExecuteSQL($query, $ph); return $this; }
function setHelp($ids) { //If needed, delete mappings first. $hglf = new HelpGroupListFactory(); $hglf->getByHelpGroupControlId($this->getId()); $help_ids = array(); foreach ($hglf as $help_group_entry) { $help_id = $help_group_entry->getHelp(); Debug::text('Help ID: ' . $help_group_entry->getHelp(), __FILE__, __LINE__, __METHOD__, 10); //Delete all items first. $help_group_entry->Delete(); } if (is_array($ids) and count($ids) > 0) { //Insert new mappings. $hgf = new HelpGroupFactory(); $i = 0; foreach ($ids as $id) { //if ( !in_array($id, $help_ids) ) { $hgf->setHelpGroupControl($this->getId()); $hgf->setOrder($i); $hgf->setHelp($id); if ($this->Validator->isTrue('help', $hgf->Validator->isValid(), TTi18n::gettext('Incorrect Help Entry'))) { $hgf->save(); } //} $i++; } //return TRUE; } return TRUE; }