public function approveSuggestion($id) { if (!Current_User::authorized('calendar', 'edit_public') || Current_User::isRestricted('calendar')) { PHPWS_Core::errorPage('403'); } PHPWS_Core::initModClass('calendar', 'Suggestion.php'); $suggestion = new Calendar_Suggestion((int) $id); if (!$suggestion->id) { PHPWS_Core::errorPage('404'); } $values = PHPWS_Core::stripObjValues($suggestion); unset($values['id']); $event = new Calendar_Event(); $event->loadSchedule($suggestion->schedule_id); $event->public = 1; PHPWS_Core::plugObject($event, $values); $result = $event->save(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); return false; } $suggestion->delete(); }
function createReport() { if ($this->class) { $methods = get_class_methods($this->class); if (in_array($this->report_row, $methods)) { $func_type = 'method'; } } if (!isset($func_type)) { if (function_exists($this->report_row)) { $func_type = 'function'; } else { $func_type = 'none'; } } $index_set = false; $tmp_file = \PHPWS_Text::randomString(10) . time(); $directory = CACHE_DIRECTORY; $file_path = sprintf('%s/%s', $directory, $tmp_file); $fp = fopen($file_path, 'w'); foreach ($this->display_rows as $foo) { if ($func_type == 'method') { $result = call_user_func(array($foo, $this->report_row)); } elseif ($func_type == 'function') { $result = call_user_func($this->report_row, $foo); } else { if (is_object($foo)) { $result = PHPWS_Core::stripObjValues($foo); } else { $result =& $foo; } } if (!$index_set) { $index_keys = array_keys($result); $row = fputcsv($fp, $index_keys); $index_set = true; } fputcsv($fp, $result); //$row = self::formatCSVRow($result); //fwrite($fp, $row); } fclose($fp); $new_file = time() . '_pager.csv'; require_once 'HTTP/Download.php'; $dl = new HTTP_Download(); $dl->setFile($file_path); $dl->setContentDisposition(HTTP_DOWNLOAD_ATTACHMENT, $new_file); $dl->setContentType('text/csv'); $dl->send(); exit; }
public function saveSettings() { $db = new PHPWS_DB('layout_config'); $vars = PHPWS_Core::stripObjValues($this); unset($vars['current_theme']); unset($vars['_contentVars']); unset($vars['_boxes']); unset($vars['_box_order']); unset($vars['_move_box']); unset($vars['_theme_variables']); unset($vars['_default_box']); unset($vars['_style_sheets']); unset($vars['_extra_styles']); unset($vars['_key_styles']); unset($vars['_allowed_move']); $db->addValue($vars); return $db->update(); }
/** * Accepts an associative array or object. Looks for form elements with the * same names as the variables in the object or the keys in the array. If * matching elements are found, their value, match, or checked parameters * are set based upon the element type. */ public function plugIn($values) { if (is_object($values)) { $aVal = PHPWS_Core::stripObjValues($values); } else { $aVal =& $values; } if (empty($aVal) || !is_array($aVal)) { return false; } foreach ($aVal as $name => $element) { if (!isset($this->types[$name])) { continue; } $element_type = $this->types[$name]; if (!empty($element_type)) { switch ($element_type) { case 'hidden': case 'text': case 'textarea': case 'submit': case 'button': $this->setValue($name, $element); break; case 'select': case 'multiple': case 'radio': case 'check': $this->setMatch($name, $element); break; } } } }