function getfact($which) { // check to see if we should call out facts on the page $callout = isset($_GET['showfacts']) ? true : false; // get record if (is_numeric($which)) { if (!$fact = Fact::findById($which)) return '<span class="fact-broken" title="broken fact"'.($callout ? ' style="background:#FFCFCF;" ' : '' ).'>[fact id('.$which.') not found]</span>'; } else { if (!$fact = Fact::findByName($which)) return '<span class="fact-broken" title="broken fact"'.($callout ? ' style="background:#FFCFCF;" ' : '' ).'>[fact "'.$which.'" not found]</span>'; } // return fact return '<span class="fact" title="Fact #'.$fact->id.' | '.$fact->name.'"'.($callout ? ' style="background:#A1DFC1;" ' : '' ).'>'.$fact->data.'</span>'.(!empty($fact->url) ? '<sup><a class="fact-link" href="/fact-supporting-info/'.$fact->id.'" target="_blank" rel="nofollow">**</a></sup>' : ''); }
public function update($id=null) { // make sure user has rights to edit self::__checkPermission('facts_edit'); // check to make sure ID is set and valid if (is_null($id)) { $this->__log(__('error encountered updating fact').'; '.__('ID not specified'),self::LOG_ERROR); Flash::set('error',__('No ID specified!')); redirect(get_url('plugin/facts')); } if (!$fact = Fact::findById($id)) { $this->__log(__('error encountered updating fact').'; '.__('could not find fact by ID'),self::LOG_ERROR); Flash::set('error',__('Could not find record!')); redirect(get_url('plugin/facts')); } // retrieve the new values from $_POST $input = $this->__validate($_POST); $input['updated'] = date('Y-m-d H:i:s'); // update the record with the new values foreach ($input as $key => $value) $fact->$key = $value; if (!$fact->save()) { $this->__log(__('error encountered updating fact'),self::LOG_ERROR); Flash::set('error',__('Could not update the record in the database.')); redirect(get_url('plugin/facts/edit/'.$id)); } $this->__log(__('updated fact').' "'.$fact->name.'"'); Flash::set('success',__('Record updated!')); redirect(get_url('plugin/facts')); }//*/