/** * redirect to a site based on some URL field of the item */ function publications_user_redirect($args) { // Get parameters from user if (!xarVarFetch('id', 'id', $id, NULL, XARVAR_NOT_REQUIRED)) { return; } // Override if needed from argument array extract($args); if (!isset($id) || !is_numeric($id) || $id < 1) { return xarML('Invalid publication ID'); } // Load API if (!xarModAPILoad('publications', 'user')) { return; } // Get publication $publication = xarModAPIFunc('publications', 'user', 'get', array('id' => $id)); if (!is_array($publication)) { $msg = xarML('Failed to retrieve publication in #(3)_#(1)_#(2).php', 'user', 'get', 'publications'); throw new DataNotFoundException(null, $msg); } $ptid = $publication['pubtype_id']; // Get publication types $pubtypes = xarModAPIFunc('publications', 'user', 'get_pubtypes'); // TODO: improve this e.g. when multiple URL fields are present // Find an URL field based on the pubtype configuration foreach ($pubtypes[$ptid]['config'] as $field => $value) { if (empty($value['label'])) { continue; } if ($value['format'] == 'url' && !empty($publication[$field]) && $publication[$field] != 'http://') { // TODO: add some verifications here ! $hooks = xarModCallHooks('item', 'display', $id, array('module' => 'publications', 'itemtype' => $ptid), 'publications'); xarController::redirect($article[$field]); return true; } elseif ($value['format'] == 'urltitle' && !empty($publication[$field]) && substr($publication[$field], 0, 2) == 'a:') { $array = unserialize($publication[$field]); if (!empty($array['link']) && $array['link'] != 'http://') { $hooks = xarModCallHooks('item', 'display', $id, array('module' => 'publications', 'itemtype' => $ptid), 'publications'); xarController::redirect($array['link']); return true; } } } return xarML('Unable to find valid redirect field'); }
public function display(array $data = array()) { $data = $this->getContent(); // see if we're currently displaying an article if (xarVarIsCached('Blocks.publications', 'id')) { $curid = xarVarGetCached('Blocks.publications', 'id'); } else { $curid = -1; } if (!empty($data['dynamictitle'])) { if ($data['toptype'] == 'rating') { $data['title'] = xarML('Top Rated'); } elseif ($data['toptype'] == 'hits') { $data['title'] = xarML('Top'); } else { $data['title'] = xarML('Latest'); } } if (!empty($data['nocatlimit'])) { // don't limit by category $cid = 0; $cidsarray = array(); } else { if (!empty($data['catfilter'])) { // use admin defined category $cidsarray = array($data['catfilter']); $cid = $data['catfilter']; } else { // use the current category // Jonn: this currently only works with one category at a time // it could be reworked to support multiple cids if (xarVarIsCached('Blocks.publications', 'cids')) { $curcids = xarVarGetCached('Blocks.publications', 'cids'); if (!empty($curcids)) { if ($curid == -1) { //$cid = $curcids[0]['name']; $cid = $curcids[0]; $cidsarray = array($curcids[0]); } else { $cid = $curcids[0]; $cidsarray = array($curcids[0]); } } else { $cid = 0; $cidsarray = array(); } } else { // pull from all categories $cid = 0; $cidsarray = array(); } } //echo $includechildren; if (!empty($data['includechildren']) && !empty($cidsarray[0]) && !strstr($cidsarray[0], '_')) { $cidsarray[0] = '_' . $cidsarray[0]; } if (!empty($cid)) { // if we're viewing all items below a certain category, i.e. catid = _NN $cid = str_replace('_', '', $cid); $thiscategory = xarModAPIFunc('categories', 'user', 'getcat', array('cid' => $cid, 'return_itself' => 'return_itself')); } if (!empty($cidsarray) && isset($thiscategory[0]['name']) && !empty($data['dynamictitle'])) { $data['title'] .= ' ' . $thiscategory[0]['name']; } } // Get publication types // MarieA - moved to always get pubtypes. $publication_types = xarModAPIFunc('publications', 'user', 'get_pubtypes'); if (!empty($data['nopublimit'])) { //don't limit by publication type $ptid = 0; if (!empty($data['dynamictitle'])) { $data['title'] .= ' ' . xarML('Content'); } } else { // MikeC: Check to see if admin has specified that only a specific // Publication Type should be displayed. If not, then default to original TopItems configuration. if ($data['pubtype_id'] == 0) { if (xarVarIsCached('Blocks.publications', 'ptid')) { $ptid = xarVarGetCached('Blocks.publications', 'ptid'); } if (empty($ptid)) { // default publication type $ptid = xarModVars::get('publications', 'defaultpubtype'); } } else { // MikeC: Admin Specified a publication type, use it. $ptid = $data['pubtype_id']; } if (!empty($data['dynamictitle'])) { if (!empty($ptid) && isset($publication_types[$ptid]['description'])) { $data['title'] .= ' ' . xarVarPrepForDisplay($publication_types[$ptid]['description']); } else { $data['title'] .= ' ' . xarML('Content'); } } } // frontpage or approved state if (empty($data['pubstate'])) { $statearray = array(2, 3); } elseif (!is_array($data['pubstate'])) { $statearray = preg_split('/,/', $data['pubstate']); } else { $statearray = $data['pubstate']; } // get cids for security check in getall $fields = array('id', 'title', 'pubtype_id', 'cids'); if ($data['toptype'] == 'rating' && xarModIsHooked('ratings', 'publications', $ptid)) { array_push($fields, 'rating'); $sort = 'rating'; } elseif ($data['toptype'] == 'hits' && xarModIsHooked('hitcount', 'publications', $ptid)) { array_push($fields, 'counter'); $sort = 'hits'; } else { array_push($fields, 'create_date'); $sort = 'date'; } if (!empty($data['showsummary'])) { array_push($fields, 'summary'); } if (!empty($data['showdynamic']) && xarModIsHooked('dynamicdata', 'publications', $ptid)) { array_push($fields, 'dynamicdata'); } $publications = xarModAPIFunc('publications', 'user', 'getall', array('ptid' => $ptid, 'cids' => $cidsarray, 'andcids' => 'false', 'state' => $statearray, 'create_date' => time(), 'fields' => $fields, 'sort' => $sort, 'numitems' => $data['numitems'])); if (!isset($publications) || !is_array($publications) || count($publications) == 0) { return; } $items = array(); foreach ($publications as $article) { $article['title'] = xarVarPrepHTMLDisplay($article['title']); if ($article['id'] != $curid) { // Use the filtered category if set, and not including children $article['link'] = xarModURL('publications', 'user', 'display', array('itemid' => $article['id'], 'catid' => !empty($data['linkcat']) && !empty($data['catfilter']) ? $data['catfilter'] : NULL)); } else { $article['link'] = ''; } if (!empty($data['showvalue'])) { if ($data['toptype'] == 'rating') { if (!empty($article['rating'])) { $article['value'] = intval($article['rating']); } else { $article['value'] = 0; } } elseif ($data['toptype'] == 'hits') { if (!empty($article['counter'])) { $article['value'] = $article['counter']; } else { $article['value'] = 0; } } else { // TODO: make user-dependent if (!empty($article['create_date'])) { //$article['value'] = strftime("%Y-%m-%d", $article['create_date']); $article['value'] = xarLocaleGetFormattedDate('short', $article['create_date']); } else { $article['value'] = 0; } } } else { $article['value'] = 0; } // MikeC: Bring the summary field back as $desc if (!empty($data['showsummary'])) { $article['summary'] = xarVarPrepHTMLDisplay($article['summary']); $article['transform'] = array('summary', 'title'); $article = xarModCallHooks('item', 'transform', $article['id'], $article, 'publications'); } else { $article['summary'] = ''; } // MarieA: Bring the pubtype description back as $descr if (!empty($data['nopublimit'])) { $article['pubtypedescr'] = $publication_types[$article['pubtype_id']]['description']; //jojodee: while we are here bring the pubtype name back as well $article['pubtypename'] = $publication_types[$article['pubtype_id']]['name']; } // this will also pass any dynamic data fields (if any) $items[] = $article; } $data['items'] = $items; if (!empty($data['dynamictitle'])) { $this->setTitle($data['title']); } return $data; }
/** * This is a standard function to update the configuration parameters of the * module given the information passed back by the modification form */ function calendar_admin_updateconfig() { // Get parameters from whatever input we need. All arguments to this // function should be obtained from xarVarFetch(), xarVarCleanFromInput // is a degraded function. xarVarFetch allows the checking of the input // variables as well as setting default values if needed. Getting vars // from other places such as the environment is not allowed, as that makes // assumptions that will not hold in future versions of Xaraya if (!xarVarFetch('shorturls', 'checkbox', $shorturls, false, XARVAR_NOT_REQUIRED)) { return; } // Variables from phpIcalendar config.inc.php if (!xarVarFetch('default_view', 'isset', $default_view, 'Week', XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('minical_view', 'isset', $minical_view, 'Week', XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('default_cal', 'isset', $default_cal, array(), XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('cal_sdow', 'int:0:6', $cal_sdow, 0, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('day_start', 'isset', $day_start, '0800', XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('day_end', 'isset', $day_end, '2100', XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('gridLength', 'int:0', $gridLength, 15, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('num_years', 'int:0', $num_years, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('month_event_lines', 'int:0', $month_event_lines, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('tomorrows_events_lines', 'int:0', $tomorrows_events_lines, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('allday_week_lines', 'int:0', $allday_week_lines, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('week_events_lines', 'int:0', $week_events_lines, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('second_offset', 'int:0', $second_offset, 0, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('bleed_time', 'int:0', $bleed_time, 0, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('display_custom_goto', 'checkbox', $display_custom_goto, 0, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('display_ical_list', 'checkbox', $display_ical_list, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('allow_webcals', 'checkbox', $allow_webcals, 0, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('this_months_events', 'checkbox', $this_months_events, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('use_color_cals', 'checkbox', $use_color_cals, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('daysofweek_dayview', 'checkbox', $daysofweek_dayview, 0, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('enable_rss', 'checkbox', $enable_rss, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('show_search', 'checkbox', $show_search, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('allow_preferences', 'checkbox', $allow_preferences, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('printview_default', 'checkbox', $printview_default, 0, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('show_todos', 'checkbox', $show_todos, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('show_completed', 'checkbox', $show_completed, 0, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('allow_login', 'checkbox', $allow_login, 0, XARVAR_NOT_REQUIRED)) { return; } // Confirm authorisation code. This checks that the form had a valid // authorisation code attached to it. If it did not then the function will // proceed no further as it is possible that this is an attempt at sending // in false data to the system if (!xarSecConfirmAuthKey()) { return; } // Update module variables. Note that the default values are set in // xarVarFetch when recieving the incoming values, so no extra processing // is needed when setting the variables here. xarModVars::set('calendar', 'SupportShortURLs', $shorturls); // Variables from phpIcalendar config.inc.php xarModVars::set('calendar', 'default_view', $default_view); xarModVars::set('calendar', 'minical_view', $minical_view); xarModVars::set('calendar', 'default_cal', serialize($default_cal)); xarModVars::set('calendar', 'cal_sdow', $cal_sdow); xarModVars::set('calendar', 'day_start', $day_start); xarModVars::set('calendar', 'day_end', $day_end); xarModVars::set('calendar', 'gridLength', $gridLength); xarModVars::set('calendar', 'num_years', $num_years); xarModVars::set('calendar', 'month_event_lines', $month_event_lines); xarModVars::set('calendar', 'tomorrows_events_lines', $tomorrows_events_lines); xarModVars::set('calendar', 'allday_week_lines', $allday_week_lines); xarModVars::set('calendar', 'week_events_lines', $week_events_lines); xarModVars::set('calendar', 'second_offset', $second_offset); xarModVars::set('calendar', 'bleed_time', $bleed_time); xarModVars::set('calendar', 'display_custom_goto', $display_custom_goto); xarModVars::set('calendar', 'display_ical_list', $display_ical_list); xarModVars::set('calendar', 'allow_webcals', $allow_webcals); xarModVars::set('calendar', 'this_months_events', $this_months_events); xarModVars::set('calendar', 'use_color_cals', $use_color_cals); xarModVars::set('calendar', 'daysofweek_dayview', $daysofweek_dayview); xarModVars::set('calendar', 'enable_rss', $enable_rss); xarModVars::set('calendar', 'show_search', $show_search); xarModVars::set('calendar', 'allow_preferences', $allow_preferences); xarModVars::set('calendar', 'printview_default', $printview_default); xarModVars::set('calendar', 'show_todos', $show_todos); xarModVars::set('calendar', 'show_completed', $show_completed); xarModVars::set('calendar', 'allow_login', $allow_login); xarModCallHooks('module', 'updateconfig', 'calendar', array('module' => 'calendar')); // This function generated no output, and so now it is complete we redirect // the user to an appropriate page for them to carry on their work xarController::redirect(xarModURL('calendar', 'admin', 'modifyconfig')); // Return return true; }
function publications_admin_update() { // Get parameters if (!xarVarFetch('itemid', 'isset', $data['itemid'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('items', 'str', $items, '', XARVAR_DONT_SET)) { return; } if (!xarVarFetch('ptid', 'isset', $data['ptid'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('modify_cids', 'isset', $cids, NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('preview', 'isset', $data['preview'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('quit', 'isset', $data['quit'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('front', 'isset', $data['front'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('tab', 'str:1', $data['tab'], '', XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('returnurl', 'str:1', $data['returnurl'], 'view', XARVAR_NOT_REQUIRED)) { return; } // Confirm authorisation code // This has been disabled for now // if (!xarSecConfirmAuthKey()) return; $items = explode(',', $items); $pubtypeobject = DataObjectMaster::getObject(array('name' => 'publications_types')); $pubtypeobject->getItem(array('itemid' => $data['ptid'])); $data['object'] = DataObjectMaster::getObject(array('name' => $pubtypeobject->properties['name']->value)); // First we need to check all the data on the template // If checkInput fails, don't bail $itemsdata = array(); $isvalid = true; foreach ($items as $prefix) { $data['object']->setFieldPrefix($prefix); // Disable the celkoposition property according if this is not the base document $fieldname = $prefix . '_dd_' . $data['object']->properties['parent']->id; $data['object']->properties['parent']->checkInput($fieldname); if (empty($data['object']->properties['parent']->value)) { $data['object']->properties['position']->setDisplayStatus(DataPropertyMaster::DD_DISPLAYSTATE_DISPLAYONLY); } else { $data['object']->properties['position']->setDisplayStatus(DataPropertyMaster::DD_DISPLAYSTATE_DISABLED); } // Now get the input from the form $thisvalid = $data['object']->checkInput(); $isvalid = $isvalid && $thisvalid; // Store each item for later processing $itemsdata[$prefix] = $data['object']->getFieldValues(array(), 1); } if ($data['preview'] || !$isvalid) { // Show debug info if called for if (!$isvalid && xarModVars::get('publications', 'debugmode') && in_array(xarUserGetVar('uname'), xarConfigVars::get(null, 'Site.User.DebugAdmins'))) { var_dump($data['object']->getInvalids()); } // Preview or bad data: redisplay the form $data['properties'] = $data['object']->getProperties(); if ($data['preview']) { $data['tab'] = 'preview'; } $data['items'] = $itemsdata; // Get the settings of the publication type we are using $data['settings'] = xarModAPIFunc('publications', 'user', 'getsettings', array('ptid' => $data['ptid'])); return xarTplModule('publications', 'admin', 'modify', $data); } // call transform input hooks $article['transform'] = array('summary', 'body', 'notes'); $article = xarModCallHooks('item', 'transform-input', $data['itemid'], $article, 'publications', $data['ptid']); // Now talk to the database. Loop through all the translation pages foreach ($itemsdata as $id => $itemdata) { // Get the data for this item $data['object']->setFieldValues($itemdata, 1); // Save or create the item (depends whether this translation is new) if (empty($id)) { $item = $data['object']->createItem(); } else { $item = $data['object']->updateItem(); } // Check if we have an alias and set it as an alias of the publications module $alias_flag = $data['object']->properties['alias_flag']->value; if ($alias_flag == 1) { $alias = $data['object']->properties['alias']->value; if (!empty($alias)) { xarModAlias::set($alias, 'publications'); } } elseif ($alias_flag == 2) { $alias = $data['object']->properties['name']->value; if (!empty($alias)) { xarModAlias::set($alias, 'publications'); } } // Clear the itemid property in preparation for the next round unset($data['object']->itemid); } // Success xarSession::setVar('statusmsg', xarML('Publication Updated')); // If quitting, go to admin view; otherwise redisplay the page if (xarSecurityCheck('EditPublications', 0, 'Publication', $data['ptid'] . ':All:All:All')) { if ($data['quit']) { // Redirect if we came from somewhere else $current_listview = xarSession::getVar('publications_current_listview'); if (!empty($current_listview)) { xarController::redirect($current_listview); } xarController::redirect(xarModURL('publications', 'admin', 'view', array('ptid' => $data['ptid']))); } elseif ($data['front']) { xarController::redirect(xarModURL('publications', 'user', 'display', array('name' => $pubtypeobject->properties['name']->value, 'itemid' => $data['itemid']))); } else { xarController::redirect(xarModURL('publications', 'admin', 'modify', array('name' => $pubtypeobject->properties['name']->value, 'itemid' => $data['itemid']))); } return true; } }
function publications_admin_display($args) { // Get parameters from user // this is used to determine whether we come from a pubtype-based view or a // categories-based navigation // Note we support both id and itemid if (!xarVarFetch('name', 'str', $name, '', XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('ptid', 'id', $ptid, NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('itemid', 'id', $itemid, NULL, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('id', 'id', $id, NULL, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('page', 'int:1', $page, NULL, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('translate', 'int:1', $translate, 1, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('layout', 'str:1', $layout, 'detail', XARVAR_NOT_REQUIRED)) { return; } // Override xarVarFetch extract($args); //The itemid var takes precedence if it exiata if (isset($itemid)) { $id = $itemid; } # -------------------------------------------------------- # # If no ID supplied, try getting the id of the default page. # if (empty($id)) { $id = xarModVars::get('publications', 'defaultpage'); } # -------------------------------------------------------- # # Get the ID of the translation if required # // First save the "untranslated" id xarVarSetCached('Blocks.publications', 'current_base_id', $id); if ($translate) { $id = xarMod::apiFunc('publications', 'user', 'gettranslationid', array('id' => $id)); } # -------------------------------------------------------- # # If still no ID, check if we are trying to display a pubtype # if (empty($name) && empty($ptid) && empty($id)) { // Nothing to be done $id = xarModVars::get('publications', 'notfoundpage'); } elseif (empty($id)) { // We're missing an id but can get a pubtype: jump to the pubtype view xarController::redirect(xarModURL('publications', 'user', 'view')); } # -------------------------------------------------------- # # If still no ID, we have come to the end of the line # if (empty($id)) { return xarResponse::NotFound(); } # -------------------------------------------------------- # # We have an ID, now first get the page # // Here we get the publication type first, and then from that the page // Perhaps more efficient to get the page directly? $ptid = xarMod::apiFunc('publications', 'user', 'getitempubtype', array('itemid' => $id)); // An empty publication type means the page does not exist if (empty($ptid)) { return xarResponse::NotFound(); } /* if (empty($name) && empty($ptid)) return xarResponse::NotFound(); if(empty($ptid)) { $publication_type = DataObjectMaster::getObjectList(array('name' => 'publications_types')); $where = 'name = ' . $name; $items = $publication_type->getItems(array('where' => $where)); $item = current($items); $ptid = $item['id']; } */ $pubtypeobject = DataObjectMaster::getObject(array('name' => 'publications_types')); $pubtypeobject->getItem(array('itemid' => $ptid)); $data['object'] = DataObjectMaster::getObject(array('name' => $pubtypeobject->properties['name']->value)); // $id = xarMod::apiFunc('publications','user','gettranslationid',array('id' => $id)); $itemid = $data['object']->getItem(array('itemid' => $id)); # -------------------------------------------------------- # # Are we allowed to see this page? # $accessconstraints = unserialize($data['object']->properties['access']->value); $access = DataPropertyMaster::getProperty(array('name' => 'access')); $allow = $access->check($accessconstraints['display']); $nopublish = time() < $data['object']->properties['start_date']->value || time() > $data['object']->properties['end_date']->value && !$data['object']->properties['no_end']->value; // If no access, then bail showing a forbidden or an empty page if (!$allow || $nopublish) { if ($accessconstraints['display']['failure']) { return xarResponse::Forbidden(); } else { return xarTplModule('publications', 'user', 'empty'); } } # -------------------------------------------------------- # # If this is a redirect page, then send it on its way now # $redirect_type = $data['object']->properties['redirect_flag']->value; if ($redirect_type == 1) { // This is a simple redirect to another page try { $url = $data['object']->properties['redirect_url']->value; // Check if this is a Xaraya function $pos = strpos($url, 'xar'); if ($pos === 0) { eval('$url = ' . $url . ';'); } xarController::redirect($url, 301); } catch (Exception $e) { return xarResponse::NotFound(); } } elseif ($redirect_type == 2) { // This displays a page of a different module // If this is from a link of a redirect child page, use the child param as new URL if (!xarVarFetch('child', 'str', $child, NULL, XARVAR_NOT_REQUIRED)) { return; } if (!empty($child)) { // Turn entities into amps $url = urldecode($child); } else { $url = $data['object']->properties['proxy_url']->value; } // Bail if the URL is bad try { // Check if this is a Xaraya function $pos = strpos($url, 'xar'); if ($pos === 0) { eval('$url = ' . $url . ';'); } $params = parse_url($url); $params['query'] = preg_replace('/&/', '&', $params['query']); } catch (Exception $e) { return xarResponse::NotFound(); } // If this is an external link, show it without further processing if (!empty($params['host']) && $params['host'] != xarServer::getHost() && $params['host'] . ":" . $params['port'] != xarServer::getHost()) { xarController::redirect($url, 301); } else { parse_str($params['query'], $info); $other_params = $info; unset($other_params['module']); unset($other_params['type']); unset($other_params['func']); unset($other_params['child']); try { $page = xarMod::guiFunc($info['module'], 'user', $info['func'], $other_params); } catch (Exception $e) { return xarResponse::NotFound(); } // Debug // echo xarModURL($info['module'],'user',$info['func'],$other_params); # -------------------------------------------------------- # # For proxy pages: the transform of the subordinate function's template # // Find the URLs in submits $pattern = '/(action)="([^"\\r\\n]*)"/'; preg_match_all($pattern, $page, $matches); $pattern = array(); $replace = array(); foreach ($matches[2] as $match) { $pattern[] = '%</form%'; $replace[] = '<input type="hidden" name="return_url" id="return_url" value="' . urlencode(xarServer::getCurrentURL()) . '"/><input type="hidden" name="child" value="' . urlencode($match) . '"/></form'; } $page = preg_replace($pattern, $replace, $page); $pattern = '/(action)="([^"\\r\\n]*)"/'; $page = preg_replace_callback($pattern, create_function('$matches', 'return $matches[1]."=\\"".xarServer::getCurrentURL()."\\"";'), $page); // Find the URLs in links $pattern = '/(href)="([^"\\r\\n]*)"/'; $page = preg_replace_callback($pattern, create_function('$matches', 'return $matches[1]."=\\"".xarServer::getCurrentURL(array("child" => urlencode($matches[2])))."\\"";'), $page); return $page; } } # -------------------------------------------------------- # # If this is a bloccklayout page, then process it # if ($data['object']->properties['pagetype']->value == 2) { // Get a copy of the compiler sys::import('xaraya.templating.compiler'); $blCompiler = XarayaCompiler::instance(); // Get the data fields $fields = array(); $sourcefields = array('title', 'description', 'summary', 'body1', 'body2', 'body3', 'body4', 'body5', 'notes'); $prefix = strlen('publications.') - 1; foreach ($data['object']->properties as $prop) { if (in_array(substr($prop->source, $prefix), $sourcefields)) { $fields[] = $prop->name; } } // Run each template field through the compiler foreach ($fields as $field) { try { $tplString = '<xar:template xmlns:xar="http://xaraya.com/2004/blocklayout">'; $tplString .= xarMod::apiFunc('publications', 'user', 'prepareforbl', array('string' => $data['object']->properties[$field]->value)); $tplString .= '</xar:template>'; $tplString = $blCompiler->compilestring($tplString); // We don't allow passing $data to the template for now $tpldata = array(); $tplString = xarTplString($tplString, $tpldata); } catch (Exception $e) { var_dump($tplString); } $data['object']->properties[$field]->value = $tplString; } } # -------------------------------------------------------- # # Get the complete tree for this section of pages. We need this for blocks etc. # $tree = xarMod::apiFunc('publications', 'user', 'getpagestree', array('tree_contains_pid' => $id, 'key' => 'id', 'status' => 'ACTIVE,FRONTPAGE,PLACEHOLDER')); // If this page is of type PLACEHOLDER, then look in its descendents if ($data['object']->properties['state']->value == 5) { // Scan for a descendent that is ACTIVE or FRONTPAGE if (!empty($tree['pages'][$id]['child_keys'])) { foreach ($tree['pages'][$id]['child_keys'] as $scan_key) { // If the page is displayable, then treat it as the new page. if ($tree['pages'][$scan_key]['status'] == 3 || $tree['pages'][$scan_key]['status'] == 4) { $id = $tree['pages'][$scan_key]['id']; $id = xarMod::apiFunc('publications', 'user', 'gettranslationid', array('id' => $id)); $itemid = $data['object']->getItem(array('itemid' => $id)); break; } } } } # -------------------------------------------------------- # # Additional data # // Pass the layout to the template $data['layout'] = $layout; // Get the settings for this publication type; $data['settings'] = xarModAPIFunc('publications', 'user', 'getsettings', array('ptid' => $ptid)); // The name of this object $data['objectname'] = $data['object']->name; # -------------------------------------------------------- # # Set the theme if needed # if (!empty($data['object']->properties['theme']->value)) { xarTplSetThemeName($data['object']->properties['theme']->value); } # -------------------------------------------------------- # # Set the page template from the pubtype if needed # if (!empty($data['settings']['page_template'])) { $pagename = $data['settings']['page_template']; $position = strpos($pagename, '.'); if ($position === false) { $pagetemplate = $pagename; } else { $pagetemplate = substr($pagename, 0, $position); } xarTpl::setPageTemplateName($pagetemplate); } // It can be overridden by the page itself if (!empty($data['object']->properties['page_template']->value)) { $pagename = $data['object']->properties['page_template']->value; $position = strpos($pagename, '.'); if ($position === false) { $pagetemplate = $pagename; } else { $pagetemplate = substr($pagename, 0, $position); } xarTpl::setPageTemplateName($pagetemplate); } # -------------------------------------------------------- # # Cache data for blocks # // Now we can cache all this data away for the blocks. // The blocks should have access to most of the same data as the page. xarVarSetCached('Blocks.publications', 'pagedata', $tree); // The 'serialize' hack ensures we have a proper copy of the // paga data, which is a self-referencing array. If we don't // do this, then any changes we make will affect the stored version. $data = unserialize(serialize($data)); // Save some values. These are used by blocks in 'automatic' mode. xarVarSetCached('Blocks.publications', 'current_id', $id); xarVarSetCached('Blocks.publications', 'ptid', $ptid); xarVarSetCached('Blocks.publications', 'author', $data['object']->properties['author']->value); # -------------------------------------------------------- # # Make the properties available to the template # $data['properties'] =& $data['object']->properties; return $data; /* // TEST - highlight search terms if(!xarVarFetch('q', 'str', $q, NULL, XARVAR_NOT_REQUIRED)) {return;} */ // Override if needed from argument array (e.g. preview) extract($args); // Defaults if (!isset($page)) { $page = 1; } // via arguments only if (!isset($preview)) { $preview = 0; } /* if ($preview) { if (!isset($publication)) { return xarML('Invalid publication'); } $id = $publication->properties['id']->value; } elseif (!isset($id) || !is_numeric($id) || $id < 1) { return xarML('Invalid publication ID'); } */ /* // Get publication if (!$preview) { $publication = xarModAPIFunc('publications', 'user', 'get', array('id' => $id, 'withcids' => true)); } if (!is_array($publication)) { $msg = xarML('Failed to retrieve publication in #(3)_#(1)_#(2).php', 'userapi', 'get', 'publications'); throw new DataNotFoundException(null, $msg); } // Get publication types $pubtypes = xarModAPIFunc('publications','user','get_pubtypes'); // Check that the publication type is valid, otherwise use the publication's pubtype if (!empty($ptid) && !isset($pubtypes[$ptid])) { $ptid = $publication['pubtype_id']; } */ // keep original ptid (if any) // $ptid = $publication['pubtype_id']; // $pubtype_id = $publication->properties['itemtype']->value; // $owner = $publication->properties['author']->value; /* if (!isset($publication['cids'])) { $publication['cids'] = array(); } $cids = $publication['cids']; */ // Get the publication settings for this publication type if (empty($ptid)) { $settings = unserialize(xarModVars::get('publications', 'settings')); } else { $settings = unserialize(xarModVars::get('publications', 'settings.' . $ptid)); } // show the number of publications for each publication type if (!isset($show_pubcount)) { if (!isset($settings['show_pubcount']) || !empty($settings['show_pubcount'])) { $show_pubcount = 1; // default yes } else { $show_pubcount = 0; } } // show the number of publications for each category if (!isset($show_catcount)) { if (empty($settings['show_catcount'])) { $show_catcount = 0; // default no } else { $show_catcount = 1; } } // Initialize the data array $data = $publication->getFieldValues(); $data['ptid'] = $ptid; // navigation pubtype $data['pubtype_id'] = $pubtype_id; // publication pubtype // TODO: improve the case where we have several icons :) $data['topic_icons'] = ''; $data['topic_images'] = array(); $data['topic_urls'] = array(); $data['topic_names'] = array(); /* if (count($cids) > 0) { if (!xarModAPILoad('categories', 'user')) return; $catlist = xarModAPIFunc('categories', 'user', 'getcatinfo', array('cids' => $cids)); foreach ($catlist as $cat) { $link = xarModURL('publications','user','view', array(//'state' => array(PUBLICATIONS_STATE_FRONTPAGE,PUBLICATIONS_STATE_APPROVED). 'ptid' => $ptid, 'catid' => $cat['cid'])); $name = xarVarPrepForDisplay($cat['name']); $data['topic_urls'][] = $link; $data['topic_names'][] = $name; if (!empty($cat['image'])) { $image = xarTplGetImage($cat['image'],'categories'); $data['topic_icons'] .= '<a href="'. $link .'">'. '<img src="'. $image . '" alt="'. $name .'" />'. '</a>'; $data['topic_images'][] = $image; break; } } } */ // multi-page output for 'body' field (mostly for sections at the moment) $themeName = xarVarGetCached('Themes.name', 'CurrentTheme'); if ($themeName != 'print') { if (strstr($publication->properties['body']->value, '<!--pagebreak-->')) { if ($preview) { $publication['body'] = preg_replace('/<!--pagebreak-->/', '<hr/><div style="text-align: center;">' . xarML('Page Break') . '</div><hr/>', $publication->properties['body']->value); $data['previous'] = ''; $data['next'] = ''; } else { $pages = explode('<!--pagebreak-->', $publication->properties['body']->value); // For documents with many pages, the pages can be // arranged in blocks. $pageBlockSize = 10; // Get pager information: one item per page. $pagerinfo = xarTplPagerInfo(empty($page) ? 1 : $page, count($pages), 1, $pageBlockSize); // Retrieve current page and total pages from the pager info. // These will have been normalised to ensure they are in range. $page = $pagerinfo['currentpage']; $numpages = $pagerinfo['totalpages']; // Discard everything but the current page. $publication['body'] = $pages[$page - 1]; unset($pages); if ($page > 1) { // Don't count page hits after the first page. xarVarSetCached('Hooks.hitcount', 'nocount', 1); } // Pass in the pager info so a complete custom pager // can be created in the template if required. $data['pagerinfo'] = $pagerinfo; // Get the rendered pager. // The pager template (last parameter) could be an // option for the publication type. $urlmask = xarModURL('publications', 'user', 'display', array('ptid' => $ptid, 'id' => $id, 'page' => '%%')); $data['pager'] = xarTplGetPager($page, $numpages, $urlmask, 1, $pageBlockSize, 'multipage'); // Next two assignments for legacy templates. // TODO: deprecate them? $data['next'] = xarTplGetPager($page, $numpages, $urlmask, 1, $pageBlockSize, 'multipagenext'); $data['previous'] = xarTplGetPager($page, $numpages, $urlmask, 1, $pageBlockSize, 'multipageprev'); } } else { $data['previous'] = ''; $data['next'] = ''; } } else { $publication['body'] = preg_replace('/<!--pagebreak-->/', '', $publication['body']); } // TEST if (isset($prevnextart)) { $settings['prevnextart'] = $prevnextart; } if (!empty($settings['prevnextart']) && $preview == 0) { if (!array_key_exists('defaultsort', $settings)) { $settings['defaultsort'] = 'id'; } $prevart = xarModAPIFunc('publications', 'user', 'getprevious', array('id' => $id, 'ptid' => $ptid, 'sort' => $settings['defaultsort'], 'state' => array(PUBLICATIONS_STATE_FRONTPAGE, PUBLICATIONS_STATE_APPROVED), 'enddate' => time())); if (!empty($prevart['id'])) { //Make all previous publication info available to template $data['prevartinfo'] = $prevart; $data['prevart'] = xarModURL('publications', 'user', 'display', array('ptid' => $prevart['pubtype_id'], 'id' => $prevart['id'])); } else { $data['prevart'] = ''; } $nextart = xarModAPIFunc('publications', 'user', 'getnext', array('id' => $id, 'ptid' => $ptid, 'sort' => $settings['defaultsort'], 'state' => array(PUBLICATIONS_STATE_FRONTPAGE, PUBLICATIONS_STATE_APPROVED), 'enddate' => time())); if (!empty($nextart['id'])) { //Make all next art info available to template $data['nextartinfo'] = $nextart; $data['nextart'] = xarModURL('publications', 'user', 'display', array('ptid' => $nextart['pubtype_id'], 'id' => $nextart['id'])); } else { $data['nextart'] = ''; } } else { $data['prevart'] = ''; $data['nextart'] = ''; } // Display publication unset($publication); // temp. fix to include dynamic data fields without changing templates if (xarModIsHooked('dynamicdata', 'publications', $pubtype_id)) { list($properties) = xarModAPIFunc('dynamicdata', 'user', 'getitemfordisplay', array('module' => 'publications', 'itemtype' => $pubtype_id, 'itemid' => $id, 'preview' => $preview)); if (!empty($properties) && count($properties) > 0) { foreach (array_keys($properties) as $field) { $data[$field] = $properties[$field]->getValue(); // POOR mans flagging for transform hooks try { $configuration = $properties[$field]->configuration; if (substr($configuration, 0, 10) == 'transform:') { $data['transform'][] = $field; } } catch (Exception $e) { } // TODO: clean up this temporary fix $data[$field . '_output'] = $properties[$field]->showOutput(); } } } // Let any transformation hooks know that we want to transform some text. // You'll need to specify the item id, and an array containing all the // pieces of text that you want to transform (e.g. for autolinks, wiki, // smilies, bbcode, ...). $data['itemtype'] = $pubtype_id; // TODO: what about transforming DDfields ? // <mrb> see above for a hack, needs to be a lot better. // Summary is always included, is that handled somewhere else? (publication config says i can ex/include it) // <mikespub> publications config allows you to call transforms for the publications summaries in the view function if (!isset($title_transform)) { if (empty($settings['title_transform'])) { $data['transform'][] = 'summary'; $data['transform'][] = 'body'; $data['transform'][] = 'notes'; } else { $data['transform'][] = 'title'; $data['transform'][] = 'summary'; $data['transform'][] = 'body'; $data['transform'][] = 'notes'; } } $data = xarModCallHooks('item', 'transform', $id, $data, 'publications'); return xarTplModule('publications', 'user', 'display', $data); if (!empty($data['title'])) { // CHECKME: <rabbit> Strip tags out of the title - the <title> tag shouldn't have any other tags in it. $title = strip_tags($data['title']); xarTplSetPageTitle(xarVarPrepForDisplay($title), xarVarPrepForDisplay($pubtypes[$data['itemtype']]['description'])); // Save some variables to (temporary) cache for use in blocks etc. xarVarSetCached('Comments.title', 'title', $data['title']); } /* if (!empty($q)) { // TODO: split $q into search terms + add style (cfr. handlesearch in search module) foreach ($data['transform'] as $field) { $data[$field] = preg_replace("/$q/","<span class=\"xar-search-match\">$q</span>",$data[$field]); } } */ // Navigation links $data['publabel'] = xarML('Publication'); $data['publinks'] = array(); //xarModAPIFunc('publications','user','getpublinks', // array('state' => array(PUBLICATIONS_STATE_FRONTPAGE,PUBLICATIONS_STATE_APPROVED), // 'count' => $show_pubcount)); if (isset($show_map)) { $settings['show_map'] = $show_map; } if (!empty($settings['show_map'])) { $data['maplabel'] = xarML('View Publication Map'); $data['maplink'] = xarModURL('publications', 'user', 'viewmap', array('ptid' => $ptid)); } if (isset($show_archives)) { $settings['show_archives'] = $show_archives; } if (!empty($settings['show_archives'])) { $data['archivelabel'] = xarML('View Archives'); $data['archivelink'] = xarModURL('publications', 'user', 'archive', array('ptid' => $ptid)); } if (isset($show_publinks)) { $settings['show_publinks'] = $show_publinks; } if (!empty($settings['show_publinks'])) { $data['show_publinks'] = 1; } else { $data['show_publinks'] = 0; } $data['show_catcount'] = $show_catcount; // Tell the hitcount hook not to display the hitcount, but to save it // in the variable cache. if (xarModIsHooked('hitcount', 'publications', $pubtype_id)) { xarVarSetCached('Hooks.hitcount', 'save', 1); $data['dohitcount'] = 1; } else { $data['dohitcount'] = 0; } // Tell the ratings hook to save the rating in the variable cache. if (xarModIsHooked('ratings', 'publications', $pubtype_id)) { xarVarSetCached('Hooks.ratings', 'save', 1); $data['doratings'] = 1; } else { $data['doratings'] = 0; } // Retrieve the current hitcount from the variable cache if ($data['dohitcount'] && xarVarIsCached('Hooks.hitcount', 'value')) { $data['counter'] = xarVarGetCached('Hooks.hitcount', 'value'); } else { $data['counter'] = ''; } // Retrieve the current rating from the variable cache if ($data['doratings'] && xarVarIsCached('Hooks.ratings', 'value')) { $data['rating'] = intval(xarVarGetCached('Hooks.ratings', 'value')); } else { $data['rating'] = ''; } // Save some variables to (temporary) cache for use in blocks etc. xarVarSetCached('Blocks.publications', 'title', $data['title']); // Generating keywords from the API now instead of setting the entire // body into the cache. $keywords = xarModAPIFunc('publications', 'user', 'generatekeywords', array('incomingkey' => $data['body'])); xarVarSetCached('Blocks.publications', 'body', $keywords); xarVarSetCached('Blocks.publications', 'summary', $data['summary']); xarVarSetCached('Blocks.publications', 'id', $id); xarVarSetCached('Blocks.publications', 'ptid', $ptid); xarVarSetCached('Blocks.publications', 'cids', $cids); xarVarSetCached('Blocks.publications', 'owner', $owner); if (isset($data['author'])) { xarVarSetCached('Blocks.publications', 'author', $data['author']); } // TODO: add this to publications configuration ? //if ($shownavigation) { $data['id'] = $id; $data['cids'] = $cids; xarVarSetCached('Blocks.categories', 'module', 'publications'); xarVarSetCached('Blocks.categories', 'itemtype', $ptid); xarVarSetCached('Blocks.categories', 'itemid', $id); xarVarSetCached('Blocks.categories', 'cids', $cids); if (!empty($ptid) && !empty($pubtypes[$ptid]['description'])) { xarVarSetCached('Blocks.categories', 'title', $pubtypes[$ptid]['description']); } // optional category count if ($show_catcount && !empty($ptid)) { $pubcatcount = xarModAPIFunc('publications', 'user', 'getpubcatcount', array('state' => array(PUBLICATIONS_STATE_FRONTPAGE, PUBLICATIONS_STATE_APPROVED), 'ptid' => $ptid)); if (!empty($pubcatcount[$ptid])) { xarVarSetCached('Blocks.categories', 'catcount', $pubcatcount[$ptid]); } } else { // xarVarSetCached('Blocks.categories','catcount',array()); } //} // Module template depending on publication type $template = $pubtypes[$pubtype_id]['name']; // Page template depending on publication type (optional) // Note : this cannot be overridden in templates if (empty($preview) && !empty($settings['page_template'])) { xarTplSetPageTemplateName($settings['page_template']); } // Specific layout within a template (optional) if (isset($layout)) { $data['layout'] = $layout; } $pubtypeobject = DataObjectMaster::getObject(array('name' => 'publications_types')); $pubtypeobject->getItem(array('itemid' => $ptid)); $data['object'] = DataObjectMaster::getObject(array('name' => $pubtypeobject->properties['name']->value)); $id = xarMod::apiFunc('publications', 'user', 'getranslationid', array('id' => $id)); $data['object']->getItem(array('itemid' => $id)); return xarTplModule('publications', 'user', 'display', $data, $template); }
function publications_user_update() { // Get parameters if (!xarVarFetch('itemid', 'isset', $itemid, NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('items', 'str', $items, '', XARVAR_DONT_SET)) { return; } if (!xarVarFetch('ptid', 'isset', $data['ptid'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('modify_cids', 'isset', $cids, NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('preview', 'isset', $data['preview'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('quit', 'isset', $data['quit'], NULL, XARVAR_DONT_SET)) { return; } if (!xarVarFetch('tab', 'str:1', $data['tab'], '', XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('returnurl', 'str:1', $data['returnurl'], 'view', XARVAR_NOT_REQUIRED)) { return; } // Confirm authorisation code // This has been disabled for now // if (!xarSecConfirmAuthKey()) return; $items = explode(',', $items); $pubtypeobject = DataObjectMaster::getObject(array('name' => 'publications_types')); $pubtypeobject->getItem(array('itemid' => $data['ptid'])); $data['object'] = DataObjectMaster::getObject(array('name' => $pubtypeobject->properties['name']->value)); $isvalid = $data['object']->checkInput(); // First we need to check all the data on the template // If checkInput fails, don't bail $itemsdata = array(); $isvalid = true; /*foreach ($items as $prefix) { $data['object']->setFieldPrefix($prefix); $thisvalid = $data['object']->checkInput(); $isvalid = $isvalid && $thisvalid; // Store each item for later processing $itemsdata[$prefix] = $data['object']->getFieldValues(array(),1); }*/ if ($data['preview'] || !$isvalid) { // Preview or bad data: redisplay the form $data['properties'] = $data['object']->getProperties(); if ($data['preview']) { $data['tab'] = 'preview'; } $data['items'] = $itemsdata; // Get the settings of the publication type we are using $data['settings'] = xarModAPIFunc('publications', 'user', 'getsettings', array('ptid' => $data['ptid'])); return xarTplModule('publications', 'user', 'modify', $data); } // call transform input hooks $article['transform'] = array('summary', 'body', 'notes'); $article = xarModCallHooks('item', 'transform-input', $itemid, $article, 'publications', $data['ptid']); // Now talk to the database /*foreach ($itemsdata as $itemid => $itemdata) { $data['object']->setFieldValues($itemdata); if (empty($itemid)) $item = $data['object']->createItem(); else $item = $data['object']->updateItem(); // Clear the itemid property in preparation for the next round unset($data['object']->itemid); }*/ if (empty($itemid)) { $item = $data['object']->createItem(); } else { $item = $data['object']->updateItem(); } // Success xarSession::setVar('statusmsg', xarML('Publication Updated')); // if we can edit publications, go to admin view, otherwise go to user view if (xarSecurityCheck('EditPublications', 0, 'Publication', $data['ptid'] . ':All:All:All')) { if ($data['quit']) { xarController::redirect(xarModURL('publications', 'user', 'view', array('ptid' => $data['ptid']))); return true; } else { xarController::redirect(xarModURL('publications', 'user', 'modify', array('name' => $pubtypeobject->properties['name']->value, 'itemid' => $itemid))); return true; } } return true; }
/** * Delete a calendar from database * Usage : if (xarMod::apiFunc('calendar', 'admin', 'delete', $calendar)) {...} * * @param $args['calid'] ID of the calendar * @returns bool * @return true on success, false on failure */ function calendar_adminapi_delete_calendar($args) { // Get arguments from argument array extract($args); // Argument check if (!isset($calid)) { $msg = xarML('Invalid #(1) for #(2) function #(3)() in module #(4)', 'calendar ID', 'admin', 'delete', 'Calendar'); throw new Exception($msg); } // TODO: Security check /* if (!xarMod::apiLoad('calendar', 'user')) return; $args['mask'] = 'DeleteCalendars'; if (!xarMod::apiFunc('calendar','user','checksecurity',$args)) { $msg = xarML('Not authorized to delete #(1) items', 'Calendar'); throw new Exception($msg); } */ // Call delete hooks for categories, hitcount etc. $args['module'] = 'calendar'; $args['itemid'] = $calid; xarModCallHooks('item', 'delete', $calid, $args); // Get database setup $dbconn = xarDB::getConn(); $xartable = xarDB::getTables(); $calendarstable = $xartable['calendars']; $cal_filestable = $xartable['calendars_files']; $calfiles = $xartable['calfiles']; // Get files associated with that calendar $query = "SELECT xar_files_id FROM {$cal_filestable}\n WHERE xar_calendars_id = ? LIMIT 1 "; $result =& $dbconn->Execute($query, array($calid)); if (!$result) { return; } for (; !$result->EOF; $result->MoveNext()) { // there should be only one result list($file_id) = $result->fields; } if (isset($file_id) || !empty($file_id)) { $query = "DELETE FROM {$calfiles}\n WHERE xar_id = ?"; $result =& $dbconn->Execute($query, array($file_id)); if (!$result) { return; } } // Delete item $query = "DELETE FROM {$calendarstable}\n WHERE xar_id = ?"; $result =& $dbconn->Execute($query, array($calid)); if (!$result) { return; } $query = "DELETE FROM {$cal_filestable}\n WHERE xar_calendars_id = ?"; $result =& $dbconn->Execute($query, array($calid)); if (!$result) { return; } $result->Close(); return true; }
function wurfl_admin_modifyconfig_utility() { // Security Check if (!xarSecurityCheck('AdminWurfl')) { return; } if (!xarVarFetch('phase', 'str:1:100', $phase, 'modify', XARVAR_NOT_REQUIRED, XARVAR_PREP_FOR_DISPLAY)) { return; } if (!xarVarFetch('tab', 'str:1:100', $data['tab'], 'wurfl_general', XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('tabmodule', 'str:1:100', $tabmodule, 'wurfl', XARVAR_NOT_REQUIRED)) { return; } $hooks = xarModCallHooks('module', 'getconfig', 'wurfl'); if (!empty($hooks) && isset($hooks['tabs'])) { foreach ($hooks['tabs'] as $key => $row) { $configarea[$key] = $row['configarea']; $configtitle[$key] = $row['configtitle']; $configcontent[$key] = $row['configcontent']; } array_multisort($configtitle, SORT_ASC, $hooks['tabs']); } else { $hooks['tabs'] = array(); } $regid = xarMod::getRegID($tabmodule); switch (strtolower($phase)) { case 'modify': default: switch ($data['tab']) { case 'wurfl_general': break; case 'tab2': break; case 'tab3': break; default: break; } break; case 'update': // Confirm authorisation code if (!xarSecConfirmAuthKey()) { return; } if (!xarVarFetch('items_per_page', 'int', $items_per_page, xarModVars::get('wurfl', 'items_per_page'), XARVAR_NOT_REQUIRED, XARVAR_PREP_FOR_DISPLAY)) { return; } if (!xarVarFetch('shorturls', 'checkbox', $shorturls, false, XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('modulealias', 'checkbox', $use_module_alias, xarModVars::get('wurfl', 'use_module_alias'), XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('module_alias_name', 'str', $module_alias_name, xarModVars::get('wurfl', 'module_alias_name'), XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('defaultmastertable', 'str', $defaultmastertable, xarModVars::get('wurfl', 'defaultmastertable'), XARVAR_NOT_REQUIRED)) { return; } if (!xarVarFetch('bar', 'str:1', $bar, 'Bar', XARVAR_NOT_REQUIRED)) { return; } $modvars = array('defaultmastertable', 'bar'); if ($data['tab'] == 'wurfl_general') { xarModVars::set('wurfl', 'items_per_page', $items_per_page); xarModVars::set('wurfl', 'supportshorturls', $shorturls); xarModVars::set('wurfl', 'use_module_alias', $use_module_alias); xarModVars::set('wurfl', 'module_alias_name', $module_alias_name); foreach ($modvars as $var) { if (isset(${$var})) { xarModVars::set('wurfl', $var, ${$var}); } } } foreach ($modvars as $var) { if (isset(${$var})) { xarModItemVars::set('wurfl', $var, ${$var}, $regid); } } xarController::redirect(xarModURL('wurfl', 'admin', 'modifyconfig', array('tabmodule' => $tabmodule, 'tab' => $data['tab']))); // Return return true; break; } $data['hooks'] = $hooks; $data['tabmodule'] = $tabmodule; $data['authid'] = xarSecGenAuthKey(); return $data; }