/** * Saves admin custom data * Called when an admin is saved * * @param string $updated true if there has been an update to the user * @param object $userobj admin user object * @param string $i prefix for the admin * @param bool $alter will be true if critical admin data may be altered * @return bool */ function user_groups_save_admin($updated, $userobj, $i, $alter) { global $_zp_authority; if ($alter) { $administrators = $_zp_authority->getAdministrators('all'); if (isset($_POST[$i . 'group'])) { $groupname = sanitize($_POST[$i . 'group']); $oldgroup = $userobj->getGroup(); if (empty($groupname)) { if (!empty($oldgroup)) { $group = $_zp_authority->newAdministrator($oldgroup, 0); $userobj->setRights($group->getRights()); $userobj->setObjects($group->getObjects()); } } else { $group = $_zp_authority->newAdministrator($groupname, 0); $userobj->setRights($group->getRights()); $userobj->setObjects($group->getObjects()); if ($group->getName() == 'template') { $groupname = ''; } } if ($groupname != $oldgroup) { $updated = true; $userobj->setGroup($groupname); } } } return $updated; }
/** * Merges rights for multiple group memebership or templates * @param object $userobj * @param array $groups */ static function merge_rights($userobj, $groups, $primeObjects) { global $_zp_authority; $templates = false; $objects = $primeObjects; $custom = array(); $oldgroups = $userobj->getGroup(); $oldrights = $userobj->getRights(); $oldobjects = $userobj->getObjects(); $rights = 0; foreach ($groups as $key => $groupname) { if (empty($groupname)) { // force the first template to happen $group = new Zenphoto_Administrator('', 0); $group->setName('template'); } else { $group = Zenphoto_Authority::newAdministrator($groupname, 0, false); } if ($group->loaded) { if ($group->getName() == 'template') { unset($groups[$key]); if ($userobj->getID() > 0 && !$templates) { // fetch the existing rights and objects $templates = true; // but only once! $rights = $userobj->getRights(); $objects = $userobj->getObjects(); } } $rights = $group->getRights() | $rights; $objects = array_merge($group->getObjects(), $objects); $custom[] = $group->getCustomData(); } else { unset($groups[$key]); } } $userobj->setCustomData(array_shift($custom)); // for now it is first come, first served. // unique objects $newobjects = array(); foreach ($objects as $object) { $key = serialize(array('type' => $object['type'], 'data' => $object['data'])); if (array_key_exists($key, $newobjects)) { if (array_key_exists('edit', $object)) { $newobjects[$key]['edit'] = @$newobjects[$key]['edit'] | $object['edit']; } } else { $newobjects[$key] = $object; } } $objects = array(); foreach ($newobjects as $object) { $objects[] = $object; } $userobj->setGroup($newgroups = implode(',', $groups)); $userobj->setRights($rights); $userobj->setObjects($objects); $updated = $newgroups != $oldgroups || $oldobjects != $objects || empty($newgroups) && $rights != $oldrights; return $updated; }
/** * Finalize & send mail to peple * * @param Codendi_Mail_Interface $mail * @param String $subject * @param Array $to */ function sendMail(Codendi_Mail_Interface $mail, $subject, array $to) { $mail->addAdditionalHeader("X-Codendi-Project", $this->ArtifactType->getGroup()->getUnixName()); $mail->addAdditionalHeader("X-Codendi-Artifact", $this->ArtifactType->getItemName()); $mail->addAdditionalHeader("X-Codendi-Artifact-ID", $this->getID()); $mail->setFrom($GLOBALS['sys_noreply']); $mail->setTo(join(',', $to)); $mail->setSubject($subject); $mail->send(); }
/** * When saving an element, it may need to be added to other Fabrik lists * If those lists point to the same database table. * * @param object $elementModel element * @param object $row item * * @return void */ private function addElementToOtherDbTables($elementModel, $row) { $db = FabrikWorker::getDbo(true); $list = $elementModel->getListModel()->getTable(); $origElid = $row->id; $tmpgroupModel = $elementModel->getGroup(); $config = JComponentHelper::getParams('com_fabrik'); if ($tmpgroupModel->isJoin()) { $dbname = $tmpgroupModel->getJoinModel()->getJoin()->table_join; } else { $dbname = $list->db_table_name; } $query = $db->getQuery(true); $query->select("DISTINCT(l.id) AS id, db_table_name, l.label, l.form_id, l.label AS form_label, g.id AS group_id"); $query->from("#__{package}_lists AS l"); $query->join('INNER', '#__{package}_forms AS f ON l.form_id = f.id'); $query->join('LEFT', '#__{package}_formgroup AS fg ON f.id = fg.form_id'); $query->join('LEFT', '#__{package}_groups AS g ON fg.group_id = g.id'); $query->where("db_table_name = " . $db->quote($dbname) . " AND l.id !=" . (int) $list->id . " AND is_join = 0"); $db->setQuery($query); $otherTables = $db->loadObjectList('id'); /** * $$$ rob 20/02/2012 if you have 2 lists, counters, regions and then you join regions to countries to get a new group "countries - [regions]" * Then add elements to the regions list, the above query wont find the group "countries - [regions]" to add the elements into */ $query->clear(); $query->select('DISTINCT(l.id) AS id, l.db_table_name, l.label, l.form_id, l.label AS form_label, fg.group_id AS group_id')->from('#__{package}_joins AS j')->join('LEFT', '#__{package}_formgroup AS fg ON fg.group_id = j.group_id')->join('LEFT', '#__{package}_forms AS f ON fg.form_id = f.id')->join('LEFT', '#__{package}_lists AS l ON l.form_id = f.id')->where('j.table_join = ' . $db->quote($dbname) . ' AND j.list_id <> 0 AND j.element_id = 0 AND list_id <> ' . (int) $list->id); $db->setQuery($query); $joinedLists = $db->loadObjectList('id'); $otherTables = array_merge($joinedLists, $otherTables); if (!empty($otherTables)) { /** * $$$ hugh - we use $row after this, so we need to work on a copy, otherwise * (for instance) we redirect to the wrong copy of the element */ $rowCopy = clone $row; foreach ($otherTables as $listid => $t) { $rowCopy->id = 0; $rowCopy->parent_id = $origElid; $rowCopy->group_id = $t->group_id; $rowCopy->name = str_replace('`', '', $rowCopy->name); if ($config->get('unpublish_clones', false)) { $rowCopy->published = 0; } $rowCopy->store(); // Copy join records $join = $this->getTable('join'); if ($join->load(array('element_id' => $origElid))) { $join->id = 0; unset($join->id); $join->element_id = $rowCopy->id; $join->list_id = $listid; $join->store(); } } } }
/** * called at the end of saving an element * if a new element it will run the sql to add to field, * if existing element and name changed will create query to be used later * @param object $elementModel * @param string $origColName * @return array($update, $q, $oldName, $newdesc, $origDesc, $dropKey) */ public function shouldUpdateElement(&$elementModel, $origColName = null) { $db = FabrikWorker::getDbo(); $return = array(false, '', '', '', '', false); $element =& $elementModel->getElement(); $pluginManager =& $this->getPluginManager(); $basePlugIn =& $pluginManager->getPlugIn($element->plugin, 'element'); $fbConfig =& JComponentHelper::getParams('com_fabrik'); $fabrikDb = $this->getDb(); $group =& $elementModel->getGroup(); $dropKey = false; //$$$ rob - replaced this with getting the table from the group as if we moved the element //from one group to another $this->getTable gives you the old group's table, where as we want // the new group's table //$table =& $this->getTable(); $table =& $group->getlistModel()->getTable(); // $$$ rob - if we are saving an element that wasn't attached to a group then we should // get the table id from the group's table if ($table->id == '') { $table =& $group->getlistModel()->getTable(); } // $$$ hugh - if this is a table-less form ... not much point going any // further 'cos things will go BANG if (empty($table->id)) { return $return; } if ($this->isView()) { return $return; } if ($group->isJoin()) { $tableName = $group->getJoinModel()->getJoin()->table_join; $keydata = $keydata[0]; $primaryKey = $keydata['colname']; } else { $tableName = $table->db_table_name; $primaryKey = $table->db_primary_key; } $keydata = $this->getPrimaryKeyAndExtra($tableName); // $$$ rob base plugin needs to know group info for date fields in non-join repeat groups $basePlugIn->_group =& $elementModel->_group; $objtype = $elementModel->getFieldDescription(); //the element type AFTER saving $dbdescriptions = $this->getDBFields($tableName, 'Field'); if (!$this->canAlterFields()) { $objtype = $dbdescriptions[$origColName]->Type; } if (is_null($objtype)) { return $return; } $existingfields = array_keys($dbdescriptions); $lastfield = $existingfields[count($existingfields) - 1]; $tableName = FabrikString::safeColName($tableName); $lastfield = FabrikString::safeColName($lastfield); $altered = false; if (!array_key_exists($element->name, $dbdescriptions)) { if ($origColName == '') { $fabrikDb->setQuery("ALTER TABLE {$tableName} ADD COLUMN " . FabrikString::safeColName($element->name) . " {$objtype} AFTER {$lastfield}"); if (!$fabrikDb->query()) { return JError::raiseError(500, 'alter structure: ' . $fabrikDb->getErrorMsg()); } $altered = true; } // commented out as it stops the update when changing an element name //return $return; } $thisFieldDesc = JArrayHelper::getValue($dbdescriptions, $origColName, new stdClass()); // $$$ rob the Default property for timestamps when they are set to CURRENT_TIMESTAMP // doesn't show up from getDBFields() - so presuming a timestamp field will always default // to the current timestamp (update of the field's data controller in the Extra property (on update CURRENT_TIMESTAMP) $existingDef = ''; if (isset($thisFieldDesc->Type)) { $existingDef = $thisFieldDesc->Type; if ($thisFieldDesc->Type == 'timestamp') { $existingDef .= $thisFieldDesc->Null = 'YES' ? ' NULL' : ' NOT NULL'; $existingDef .= ' DEFAULT CURRENT_TIMESTAMP'; $existingDef .= ' ' . $thisFieldDesc->Extra; } } //if its the primary 3.0 for ($k = 0; $k < count($keydata); $k++) { if ($keydata[$k]['colname'] == $origColName) { $existingDef .= " " . $keydata[$k]['extra']; } } if (!is_null($objtype)) { $lowerobjtype = strtolower(trim($objtype)); $lowerobjtype = str_replace(' not null', '', $lowerobjtype); if ($element->name == $origColName && strtolower(trim($existingDef)) == $lowerobjtype) { //no chanages to the element name or field type return $return; } $return[4] = $existingDef; $existingfields = array_keys($dbdescriptions); $lastfield = $existingfields[count($existingfields) - 1]; $element->name = FabrikString::safeColName($element->name); $tableName = FabrikString::safeColName($tableName); $lastfield = FabrikString::safeColName($lastfield); // $$$ rob this causes issues when renaming an element with the same name but different upper/lower case //if (empty($origColName) || !in_array(strtolower($origColName ), $existingfields)) { if (empty($origColName) || !in_array($origColName, $existingfields)) { if (!$altered) { $fabrikDb->setQuery("ALTER TABLE {$tableName} ADD COLUMN {$element->name} {$objtype} AFTER {$lastfield}"); if (!$fabrikDb->query()) { return JError::raiseError(500, 'alter structure: ' . $fabrikDb->getErrorMsg()); } } } else { // $$$ rob don't alter it yet - lets defer this and give the user the choice if they // really want to do this if ($this->canAlterFields()) { if ($origColName == null) { $origColName = $element->name; } else { $origColName = $fabrikDb->nameQuote($origColName); } if (strtolower($objtype) == 'blob') { $dropKey = true; } $q = "ALTER TABLE {$tableName} CHANGE {$origColName} {$element->name} {$objtype} "; if ($primaryKey == $fabrikDb->NameQuote($tableName) . "." . $element->name && $table->auto_inc) { if (!strstr($q, 'NOT NULL AUTO_INCREMENT')) { $q .= " NOT NULL AUTO_INCREMENT "; } } $origColName = FabrikString::safeColName($origColName); $return[0] = true; $return[1] = $q; $return[2] = $origColName; $return[3] = $objtype; $return[5] = $dropKey; return $return; } } } return $return; }
/** * update - update the fields in this artifact. * * @param int The artifact priority. * @param int The artifact status ID. * @param int The person to which this artifact is to be assigned. * @param string The artifact summary. * @param int The canned response. * @param string Attaching another comment. * @param int Allows you to move an artifact to another type. * @param array Array of extra fields like: array(15=>'foobar',22=>'1'); * @return boolean success. */ function update($priority, $status_id, $assigned_to, $summary, $canned_response, $details, $new_artifact_type_id, $extra_fields = array()) { /* Field-level permission checking */ if ($this->ArtifactType->userIsAdmin()) { //admin can do everything } else { //everyone else cannot modify these fields $priority = $this->getPriority(); $summary = addslashes($this->getSummary()); $canned_response = 100; $new_artifact_type_id = $this->ArtifactType->getID(); $assigned_to = $this->getAssignedTo(); if ($this->ArtifactType->userIsTechnician()) { //technician can update only certain fields //which were not overridden above } else { //submitter can no longer call this function $this->setPermissionDeniedError(); return false; } } // // They may be using an extra field "status" box so we have to remap // the status_id based on the extra field - this keeps the counters // accurate // if (count($extra_fields) > 0) { $status_id = $this->ArtifactType->remapStatus($status_id, $extra_fields); } if (!$this->getID() || !$assigned_to || !$status_id || !$canned_response || !$new_artifact_type_id) { $this->setMissingParamsError(); return false; } // Array to record which properties were changed $changes = array(); $update = false; db_begin(); // // Get a lock on this row in the database // $lock = db_query("SELECT * FROM artifact WHERE artifact_id='" . $this->getID() . "' FOR UPDATE"); $artifact_type_id = $this->ArtifactType->getID(); // // Attempt to move this Artifact to a new ArtifactType // need to instantiate new ArtifactType obj and test perms // if ($new_artifact_type_id != $artifact_type_id) { $newArtifactType = new ArtifactType($this->ArtifactType->getGroup(), $new_artifact_type_id); if (!is_object($newArtifactType) || $newArtifactType->isError()) { $this->setError('Artifact: Could not move to new ArtifactType' . $newArtifactType->getErrorMessage()); db_rollback(); return false; } // do they have perms for new ArtifactType? if (!$newArtifactType->userIsAdmin()) { $this->setPermissionDeniedError(); db_rollback(); return false; } // // Now set Assigned to 100 in the new ArtifactType // $status_id = 1; $assigned_to = '100'; //can't send a canned response when changing ArtifactType $canned_response = 100; $this->ArtifactType =& $newArtifactType; $update = true; // // This is a major problem - the extra fields // are completely different IDs, and may not even // exist in the new tracker. All extra_fields will be deleted and // then set to 100 in the new tracker. // $res = db_query("DELETE FROM artifact_extra_field_data WHERE artifact_id='" . $this->getID() . "'"); $extra_fields = array(); } $sqlu = ''; // // handle audit trail & build SQL statement // if ($this->getStatusID() != $status_id) { $this->addHistory('status_id', $this->getStatusID()); $sqlu .= " status_id='{$status_id}', "; $changes['status'] = 1; $update = true; // Reset the close_date if bug is re-opened // (otherwise stat reports will be wrong). if ($status_id == 1) { $sqlu .= " close_date='0', "; $this->addHistory('close_date', 0); } } if ($this->getPriority() != $priority) { $this->addHistory('priority', $this->getPriority()); $sqlu .= " priority='{$priority}', "; $changes['priority'] = 1; $update = true; } if ($this->getAssignedTo() != $assigned_to) { $this->addHistory('assigned_to', $this->getAssignedTo()); $sqlu .= " assigned_to='{$assigned_to}', "; $changes['assigned_to'] = 1; $update = true; } if ($summary && addslashes($this->getSummary()) != htmlspecialchars($summary)) { $this->addHistory('summary', addslashes($this->getSummary())); $sqlu .= " summary='" . htmlspecialchars($summary) . "', "; $changes['summary'] = 1; $update = true; } if ($details) { $this->addMessage($details, '', 0); $changes['details'] = 1; $send_message = true; } // // Enter the timestamp if we are changing to closed // if ($status_id != 1) { $now = time(); $sqlu .= " close_date='{$now}', "; $this->addHistory('close_date', $now); $update = true; } /* Finally, update the artifact itself */ if ($update) { $sql = "UPDATE artifact \n\t\t\t\tSET \n\t\t\t\t{$sqlu}\n\t\t\t\tgroup_artifact_id='{$new_artifact_type_id}'\n\t\t\t\tWHERE \n\t\t\t\tartifact_id='" . $this->getID() . "'\n\t\t\t\tAND group_artifact_id='{$artifact_type_id}'"; $result = db_query($sql); if (!$result || db_affected_rows($result) < 1) { $this->setError('Error - update failed!' . db_error()); db_rollback(); return false; } else { if (!$this->fetchData($this->getID())) { db_rollback(); return false; } } } //extra field handling $update = true; if (!$this->updateExtraFields($extra_fields, $changes)) { //TODO - see if anything actually did change db_rollback(); return false; } /* handle canned responses Instantiate ArtifactCanned and get the body of the message */ if ($canned_response != 100) { //don't care if this response is for this group - could be hacked $acr = new ArtifactCanned($this->ArtifactType, $canned_response); if (!$acr || !is_object($acr)) { $this->setError('Artifact: Could Not Create Canned Response Object'); } elseif ($acr->isError()) { $this->setError('Artifact: ' . $acr->getErrorMessage()); } else { $body = addslashes($acr->getBody()); if ($body) { if (!$this->addMessage(util_unconvert_htmlspecialchars($body), '', 0)) { db_rollback(); return false; } else { $send_message = true; } } else { $this->setError('Artifact: Unable to Use Canned Response'); return false; } } } if ($update || $send_message) { /* now send the email */ $this->mailFollowup(2, false, $changes); db_commit(); return true; } else { //nothing changed, so cancel the transaction $this->setError(_('Nothing Changed - Update Cancelled')); db_rollback(); return false; } }
/** * update - update this ProjectTask in the database. * * @param string The summary of this task. * @param string The detailed description of this task. * @param int The Priority of this task. * @param int The Hours estimated to complete this task. * @param int The (unix) start date of this task. * @param int The (unix) end date of this task. * @param int The status_id of this task. * @param int The category_id of this task. * @param int The percentage of completion in integer format of this task. * @param array An array of user_id's that are assigned this task. * @param array An array of project_task_id's that this task depends on. * @param int The GroupProjectID of a new subproject that you want to move this Task to. * @param int The duration of the task in days. * @param int The id of the parent task, if any. * @return boolean success. */ function update($summary, $details, $priority, $hours, $start_date, $end_date, $status_id, $category_id, $percent_complete, &$assigned_arr, &$depend_arr, $new_group_project_id, $duration = 0, $parent_id = 0) { $has_changes = false; // if any of the values passed is different from $v = new Validator(); $v->check($summary, "summary"); $v->check($priority, "priority"); $v->check($hours, "hours"); $v->check($start_date, "start date"); $v->check($end_date, "end date"); $v->check($status_id, "status"); $v->check($category_id, "category"); if (!$v->isClean()) { $this->setError($v->formErrorMsg("Must include ")); return false; } if (!$parent_id) { $parent_id = 0; } if ($this->getParentID() != $parent_id) { $has_changes = true; } if (!$duration) { $duration = 0; } if ($this->getDuration() != $duration) { $has_changes = true; } if (!$this->ProjectGroup->userIsAdmin()) { $this->setPermissionDeniedError(); return false; } /*if ( ($this->getSummary() != $summary) || ($this->getDetails() != $details) || ($this->getPriority() != $priority) || ($this->getHours() != $hours) || ($this->getStartDate() != $start_date) || ($this->getEndDate() != $end_date) || ($this->getStatusID() != $status_id) || ($this->getCategoryID() != $category_id) || ($this->getPercentComplete() != $percent_complete) ) { $has_changes = true; }*/ db_begin(); // // Attempt to move this Task to a new Subproject // need to instantiate new ProjectGroup obj and test if it works // $group_project_id = $this->ProjectGroup->getID(); if ($new_group_project_id != $group_project_id) { $newProjectGroup = new ProjectGroup($this->ProjectGroup->getGroup(), $new_group_project_id); if (!is_object($newProjectGroup) || $newProjectGroup->isError()) { $this->setError('ProjectTask: Could not move to new ProjectGroup' . $newProjectGroup->getErrorMessage()); db_rollback(); return false; } /* do they have perms for new ArtifactType? if (!$newArtifactType->userIsAdmin()) { $this->setPermissionDeniedError(); db_rollback(); return false; }*/ // // Now set ProjectGroup, Category, and Assigned to 100 in the new ProjectGroup // $status_id = 1; $category_id = '100'; unset($assigned_to); $assigned_to = array('100'); $this->ProjectGroup =& $newProjectGroup; $this->addHistory('group_project_id', $group_project_id); $has_changes = true; } if ($details) { $has_changes = true; if (!$this->addMessage($details)) { db_rollback(); return false; } } if ($this->getStatusID() != $status_id) { $this->addHistory('status_id', $this->getStatusID()); $has_changes = true; } if ($this->getCategoryID() != $category_id) { $this->addHistory('category_id', $this->getCategoryID()); $has_changes = true; } if ($this->getPriority() != $priority) { $this->addHistory('priority', $this->getPriority()); $has_changes = true; } if ($this->getSummary() != htmlspecialchars(stripslashes($summary))) { $this->addHistory('summary', addslashes($this->getSummary())); $has_changes = true; } if ($this->getPercentComplete() != $percent_complete) { $this->addHistory('percent_complete', $this->getPercentComplete()); $has_changes = true; } if ($this->getHours() != $hours) { $this->addHistory('hours', $this->getHours()); $has_changes = true; } if ($this->getStartDate() != $start_date) { $this->addHistory('start_date', $this->getStartDate()); $has_changes = true; } if ($this->getEndDate() != $end_date) { $this->addHistory('end_date', $this->getEndDate()); $has_changes = true; } $old_assigned =& $this->getAssignedTo(); $diff_assigned_array = array_diff($old_assigned, $assigned_arr); if (count($diff_assigned_array) > 0) { for ($tmp = 0; $tmp < count($old_assigned); $tmp++) { $this->addHistory('assigned_to_id', $old_assigned[$tmp]); } $has_changes = true; } $old_array =& array_keys($this->getDependentOn()); $diff_array = array_diff($old_array, array_keys($depend_arr)); if (count($diff_array) > 0) { for ($tmp = 0; $tmp < count($old_array); $tmp++) { $this->addHistory('dependent_on_id', $old_array[$tmp]); } $has_changes = true; } if (!$this->setDependentOn($depend_arr)) { db_rollback(); return false; } elseif (!$this->setAssignedTo($assigned_arr)) { db_rollback(); return false; } else { $sql = "UPDATE project_task SET\n\t\t\t\tsummary='" . htmlspecialchars($summary) . "',\n\t\t\t\tpriority='{$priority}',\n\t\t\t\thours='{$hours}',\n\t\t\t\tstart_date='{$start_date}',\n\t\t\t\tend_date='{$end_date}',\n\t\t\t\tstatus_id='{$status_id}',\n\t\t\t\tpercent_complete='{$percent_complete}',\n\t\t\t\tcategory_id='{$category_id}',\n\t\t\t\tgroup_project_id='{$new_group_project_id}',\n\t\t\t\tduration='{$duration}',\n\t\t\t\tparent_id='{$parent_id}'\n\t\t\t\tWHERE group_project_id='{$group_project_id}'\n\t\t\t\tAND project_task_id='" . $this->getID() . "'"; $res = db_query($sql); if (!$res) { $this->setError('Error On ProjectTask::update-5: ' . db_error() . $sql); db_rollback(); return false; } else { if (!$this->fetchData($this->getID())) { $this->setError('Error On ProjectTask::update-6: ' . db_error()); db_rollback(); return false; } else { if ($has_changes) { //only send email if there was any change $this->sendNotice(); } db_commit(); return true; } } } }
/** * @since 2.1.1 * when inserting into a repeat element's table, we need to fake/create the element models * as they are not stored/shown in fabrik's admin interface * @param object $elementModel * @param object $joinGroup * @param object $oJoin */ protected function fakeRepeatElementsInGroup($elementModel, &$joinGroup, $oJoin) { $joinGroup->publishedElements[] = $elementModel; $idElementModel = JModel::getInstance('Element', 'FabrikModel'); $idElementModel->getElement()->name = 'id'; $idElementModel->getElement()->group_id = $elementModel->getGroup()->getId(); $idElementModel->_group =& $elementModel->getGroup(); $idElementModel->_aFullNames['id1_1__1_'] = $oJoin->table_join . '___id'; $joinGroup->publishedElements[] = $idElementModel; $parentElement = JModel::getInstance('Element', 'FabrikModel'); $parentElement->getElement()->name = 'parent_id'; $parentElement->getElement()->group_id = $elementModel->getGroup()->getId(); $parentElement->_group =& $elementModel->getGroup(); $parentElement->_aFullNames['parent_id1_1__1_'] = $oJoin->table_join . '___parent_id'; $joinGroup->publishedElements[] = $parentElement; $repeatElement = JModel::getInstance('Element', 'FabrikModel'); $repeatElement->getElement()->name = 'repeatnum'; $repeatElement->getElement()->group_id = $elementModel->getGroup()->getId(); $repeatElement->_group =& $elementModel->getGroup(); $repeatElement->_aFullNames['parent_id1_1__1_'] = $oJoin->table_join . '___repeatnum'; $joinGroup->publishedElements[] = $repeatElement; $paramsElement = JModel::getInstance('Element', 'FabrikModel'); $paramsElement->getElement()->name = 'params'; $paramsElement->getElement()->group_id = $elementModel->getGroup()->getId(); $paramsElement->_group =& $elementModel->getGroup(); $paramsElement->_aFullNames['parent_id1_1__1_'] = $oJoin->table_join . '___params'; $joinGroup->publishedElements[] = $paramsElement; }
/** * showEditForm - Prints the form to edit a message * * @param int The Message * @return The HTML output echoed */ function showEditForm(&$msg) { $thread_id = $msg->getThreadID(); $msg_id = $msg->getID(); $posted_by = $msg->getPosterID(); $subject = $msg->getSubject(); $body = $msg->getBody(); $post_date = $msg->getPostDate(); $is_followup_to = $msg->getParentID(); $has_followups = $msg->hasFollowups(); $most_recent_date = $msg->getMostRecentDate(); $g =& $this->Forum->getGroup(); $group_id = $g->getID(); if ($this->Forum->userCanPost()) { // minor control, but anyways it should be an admin at this point echo notepad_func(); ?> <div align="center"> <form enctype="multipart/form-data" action="<?php echo util_make_url('/forum/admin/index.php'); ?> " method="post"><?php $objid = $this->Forum->getID(); ?> <input type="hidden" name="thread_id" value="<?php echo $thread_id; ?> " /> <input type="hidden" name="forum_id" value="<?php echo $objid; ?> " /> <input type="hidden" name="editmsg" value="<?php echo $msg_id; ?> " /> <input type="hidden" name="is_followup_to" value="<?php echo $is_followup_to; ?> " /> <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?> "> <input type="hidden" name="posted_by" value="<?php echo $posted_by; ?> "> <input type="hidden" name="post_date" value="<?php echo $post_date; ?> "> <input type="hidden" name="has_followups" value="<?php echo $has_followups; ?> "> <input type="hidden" name="most_recent_date" value="<?php echo $most_recent_date; ?> "> <input type="hidden" name="group_id" value="<?php echo $group_id; ?> "> <fieldset class="fieldset"> <table> <tr> <td valign="top"></td> <td valign="top"><br> <strong><?php echo _('Subject:'); ?> </strong><?php echo utils_requiredField(); ?> <br /> <input type="text" name="subject" value="<?php echo $subject; ?> " size="45" maxlength="45" /> <br> <br> <strong><?php echo _('Message:'); ?> </strong><?php echo notepad_button('document.forms[1].body'); echo utils_requiredField(); ?> <br /> <?php $GLOBALS['editor_was_set_up'] = false; $params = array(); $params['body'] = $body; $params['width'] = "800"; $params['height'] = "500"; $params['group'] = $group_id; plugin_hook("text_editor", $params); if (!$GLOBALS['editor_was_set_up']) { //if we don't have any plugin for text editor, display a simple textarea edit box echo '<textarea name="body" rows="10" cols="50">' . $body . '</textarea>'; } unset($GLOBALS['editor_was_set_up']); ?> <br> <br> <p><?php //$this->LinkAttachForm(); ?> <p><?php ?> <br /> <center><input type="submit" name="ok" value="<?php echo _('Update'); ?> " /> <input type="submit" name="cancel" value="<?php echo _('Cancel'); ?> " /></center> </p> </td> </tr> </table> </fieldset> </form> </div> <?php } }