function get_geodata() { if (!SecurityUtil::checkPermission('AddressBook::', "::", ACCESS_EDIT)) { AjaxUtil::error($this->__('Error! No authorization to access this module.')); } $val_1 = FormUtil::getPassedValue('val_1', NULL, 'GETPOST'); $val_2 = FormUtil::getPassedValue('val_2', NULL, 'GETPOST'); $val_3 = FormUtil::getPassedValue('val_3', NULL, 'GETPOST'); $val_4 = FormUtil::getPassedValue('val_4', NULL, 'GETPOST'); //GMaps test include_once 'modules/AddressBook/lib/vendor/GMaps/GoogleMapV3.php'; $key = ModUtil::getVar('AddressBook', 'google_api_key'); $map = new GoogleMapAPI(); $map->setApiKey($key); $geocode = $map->getGeocode($val_1 . ', ' . $val_2 . ', ' . $val_3 . ', ' . $val_4); if (isset($geocode['lat']) && isset($geocode['lon'])) { $result = $geocode['lat'] . ',' . $geocode['lon']; } else { $result = ''; } if (FormUtil::getPassedValue('plane', NULL, 'GETPOST')) { return $result; } return new Zikula_Response_Ajax(array('lat_lon' => $result, 'result' => $result ? true : false)); }
function wfGetWatchers($args) { $args = AjaxUtil::getArgs($args); $title = Title::newFromText($args['title']); $offset = isset($args['offset']) ? (int) $args['offset'] : false; $limit = isset($args['limit']) ? (int) $args['limit'] : false; $watchers = StructuredData::getWatchers($title, $offset, $limit); return join('', $watchers); }
public function reloadFlaggedBlock() { // Security check if (!SecurityUtil::checkPermission('IWmain:flaggedBlock:', "::", ACCESS_READ) || !UserUtil::isLoggedIn()) { AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('Sorry! No authorization to access this module.'))); } //get the headlines saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $exists = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'flagged', 'module' => 'IWmain_block_flagged', 'uid' => UserUtil::getVar('uid'), 'sv' => $sv)); $chars = 15; if (!$exists) { ModUtil::func('IWmain', 'user', 'flagged', array('where' => '', 'chars' => $chars)); } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $have_flags = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => UserUtil::getVar('uid'), 'name' => 'have_flags', 'module' => 'IWmain_block_flagged', 'sv' => $sv)); if ($have_flags != '0') { ModUtil::func('IWmain', 'user', 'flagged', array('where' => $have_flags, 'chars' => $chars)); //Posa la variable d'usuari have_news en blanc per no haver-la de tornar a llegir a la propera reiteraci� $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('uid' => UserUtil::getVar('uid'), 'name' => 'have_flags', 'module' => 'IWmain_block_flagged', 'sv' => $sv, 'value' => '0')); } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $flags = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => UserUtil::getVar('uid'), 'name' => 'flagged', 'module' => 'IWmain_block_flagged', 'sv' => $sv, 'nult' => true)); $view = Zikula_View::getInstance('IWmain', false); $view->assign('flags', $flags); $content = $view->fetch('IWmain_block_iwflagged.tpl'); return new Zikula_Response_Ajax(array('content' => $content, )); }
/** * Mediashare AJAX handler * * @copyright (C) 2007, Jorn Wildt * @link http://www.elfisk.dk * @version $Id$ * @license See license.txt */ function mediashare_ajax_getitems($args) { $items = pnModAPIFunc('mediashare', 'user', 'getMediaItems', array('albumId' => FormUtil::getPassedValue('aid'))); if ($items === false) { AjaxUtil::error(LogUtil::getErrorMessagesText(' - '), '403 Forbidden'); } $mediaItems = array(); foreach ($items as $item) { $mediaItems[] = array('id' => $item['id'], 'isExternal' => $item['mediaHandler'] == 'extapp', 'thumbnailRef' => $item['thumbnailRef'], 'previewRef' => $item['previewRef'], 'title' => $item['title']); } return array('mediaItems' => $mediaItems); }
/** * Delete specified user assignment * @author: Sara Arjona Téllez (sarjona@xtec.cat) * @param: args Array with: * - qvaid user assignment identifier * @return: Show an error or status message */ public function deleteuserassignment($args) { // Security check if (!SecurityUtil::checkPermission('IWqv::', '::', ACCESS_ADD)) { AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('Sorry! No authorization to access this module.'))); } // Get the parameters $qvaid = FormUtil::getPassedValue('qvaid', null, 'POST'); if (ModUtil::apiFunc('IWqv', 'user', 'deleteuserassignment', array('qvaid' => $qvaid))) { $output = DataUtil::formatForDisplayHTML($this->__f('Done! %1$s deleted.', $this->__('QV assignment'))); } else { $output = AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('Error! Sorry! Deletion attempt failed.'))); } AjaxUtil::output(array('qvaid' => $qvaid, 'result' => $output)); }
public function login() { $ctl = $this; $auth = $ctl->Auth; $request = $ctl->request; $session = $ctl->Session; sleep(1); if ($request->is('post')) { if ($auth->login()) { AjaxUtil::setToken($session); $ctl->redirect($auth->redirect()); return; } else { sleep(3); //ログインNGなら $session->setFlash(__('メールアドレスかパスワードが違います'), null, null, 'auth'); } } else { $auth->logout(); } $ctl->layout = 'login'; }
/** * Change the weight of a profile item. * * Parameters passed in via POST, or via GET: * ------------------------------------------ * array profilelist An array of dud item ids for which the weight should be changed. * numeric startnum The desired weight of the first item in the list minus 1 (e.g., if the weight of the first item should be 3 then startnum contains 2) * * @return mixed An AJAX result array containing a result equal to true, or an Ajax error. */ public function changeprofileweight() { $this->checkAjaxToken(); if (!SecurityUtil::checkPermission('Profile::', '::', ACCESS_ADMIN)) { throw new Zikula_Exception_Forbidden($this->__('Sorry! You do not have authorisation for this module.')); } $profilelist = $this->request->getPost()->get('profilelist', $this->request->getGet()->get('profilelist', null)); $startnum = $this->request->getPost()->get('startnum', $this->request->getGet()->get('startnum', null)); if ($startnum < 0) { AjaxUtil::error($this->__f("Error! Invalid '%s' passed.", 'startnum')); } // update the items with the new weights $items = array(); $weight = $startnum + 1; parse_str($profilelist); foreach ($profilelist as $prop_id) { if (empty($prop_id)) { continue; } $items[] = array('prop_id' => $prop_id, 'prop_weight' => $weight); $weight++; } // update the db $res = DBUtil::updateObjectArray($items, 'user_property', 'prop_id'); if (!$res) { throw new Zikula_Exception_Fatal($this->__('Error! Could not save your changes.')); } return new Zikula_Response_Ajax(array('result' => true)); }
/** * Create a blank permission and return it * * @return mixed array with new permission or Ajax error */ public function createpermission() { $this->checkAjaxToken(); $this->throwForbiddenUnless(SecurityUtil::checkPermission('Permissions::', '::', ACCESS_ADMIN)); // add a blank permission $dummyperm = array('realm' => 0, 'id' => 0, 'component' => '.*', 'instance' => '.*', 'level' => ACCESS_NONE, 'insseq' => -1); $newperm = ModUtil::apiFunc('Permissions', 'admin', 'create', $dummyperm); if ($newperm == false) { AjaxUtil::error($this->__('Error! Could not create new permission rule.')); } $accesslevels = SecurityUtil::accesslevelnames(); $newperm['instance'] = DataUtil::formatForDisplay($newperm['instance']); $newperm['component'] = DataUtil::formatForDisplay($newperm['component']); $newperm['levelname'] = $accesslevels[$newperm['level']]; $newperm['groupname'] = $this->__('Unregistered'); return new Zikula_Response_Ajax($newperm); }
/** * Open a msg content * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @param: args Array with the id of the message * @return: The message content */ public function openMsg($args) { if (!SecurityUtil::checkPermission('IWforums::', '::', ACCESS_READ)) { throw new Zikula_Exception_Fatal($this->__('Sorry! No authorization to access this module.')); } $fid = $this->request->getPost()->get('fid', ''); if (!$fid) { throw new Zikula_Exception_Fatal($this->__('no forum id')); } $fmid = $this->request->getPost()->get('fmid', ''); if (!$fmid) { throw new Zikula_Exception_Fatal($this->__('no message id')); } $ftid = $this->request->getPost()->get('ftid', ''); $u = $this->request->getPost()->get('u', ''); $oid = $this->request->getPost()->get('oid', ''); $inici = $this->request->getPost()->get('inici', ''); //get forum information $forum = ModUtil::apiFunc('IWforums', 'user', 'get', array('fid' => $fid)); if ($forum == false) { AjaxUtil::error($this->__('The forum upon which the ation had to be carried out hasn\'t been found')); } //check if user can access the forum $access = ModUtil::func('IWforums', 'user', 'access', array('fid' => $fid)); if ($access < 1) { AjaxUtil::error($this->__('You can\'t access the forum')); } //get message information $registre = ModUtil::apiFunc('IWforums', 'user', 'get_msg', array('fmid' => $fmid)); if ($registre == false) { AjaxUtil::error($this->__('No messages have been found')); } $content = ModUtil::func('IWforums', 'user', 'openMsg', array('fid' => $fid, 'fmid' => $fmid, 'ftid' => $ftid, 'u' => $u, 'oid' => $oid, 'inici' => $inici)); return new Zikula_Response_Ajax(array('fmid' => $fmid, 'content' => $content, )); }
/** * Make a category the initially selected one (by ajax). * * @return AjaxUtil::output Output to the calling ajax request is returned. * response is a string message on success. */ public function defaultCategory() { $this->checkAjaxToken(); //check user has permission to change the initially selected category $this->throwForbiddenUnless(SecurityUtil::checkPermission('Admin::', '::', ACCESS_ADMIN)); //get passed cid $cid = trim($this->request->getPost()->get('cid')); //find the category corresponding to the cid. $category = ModUtil::apiFunc('Admin', 'admin', 'get', array('cid' => $cid)); if ($category == false) { return AjaxUtil::error(LogUtil::registerError($this->__('Error! No such category found.')), array(), true); } $output = array(); //make category the initially selected one if (ModUtil::setVar('Admin', 'startcategory', $cid)) { // Success $output['response'] = $this->__f('Category "%s" was successfully made default.', $category['catname']); return new Zikula_Response_Ajax($output); } //unknown error throw new Zikula_Exception_Fatal($this->__('Error! Could not make this category default.')); }
public function externalModifyImg($args) { if (!SecurityUtil::checkPermission('Files::', '::', ACCESS_ADD)) { AjaxUtil::error(DataUtil::formatForDisplayHTML(_MODULENOAUTH)); } $image = FormUtil::getPassedValue('image', -1, 'GET'); if ($image == -1) { AjaxUtil::error($this->__('no image found')); } $factor = FormUtil::getPassedValue('factor', -1, 'GET'); if ($factor == -1) { AjaxUtil::error($this->__('no size factor defined')); } $folderName = FormUtil::getPassedValue('folder', -1, 'GET'); if ($folderName == -1) { AjaxUtil::error($this->__('No folder defined.')); } $action = FormUtil::getPassedValue('action', -1, 'GET'); $folderPath = SecurityUtil::checkPermission('Files::', '::', ACCESS_ADMIN) ? $folderName : ModUtil::getVar('Files', 'usersFolder') . '/' . strtolower(substr(UserUtil::getVar('uname'), 0, 1)) . '/' . UserUtil::getVar('uname') . '/' . $folderName; // gets root folder for the user $initFolderPath = ModUtil::func('Files', 'user', 'getInitFolderPath'); list($width, $height) = getimagesize($initFolderPath . '/' . $folderName . '/' . $image); $factor = $action == 'increase' ? round($factor / 1.2, 2) : round($factor * 1.2, 2); $newWidth = floor($width / $factor); $newHeight = floor($height / $factor); // create output object $file = array('name' => $image, 'width' => $width, 'viewWidth' => $newWidth, 'viewHeight' => $newHeight, 'height' => $height, 'factor' => $factor); // create new thumbnail ModUtil::func('Files', 'user', 'thumbnail', array('fileName' => $image, 'folder' => $folderName, 'newWidth' => $newWidth, 'fromAjax' => 1)); $this->view->setCaching(false); $this->view->assign('file', $file); $this->view->assign('folderPath', $folderPath); $this->view->assign('folderName', $folderName); $this->view->assign('hook', 0); $content = $this->view->fetch('Files_external_getFilesImgContent.tpl'); AjaxUtil::output(array('image' => $image, 'content' => $content)); }
/** * toggleContentState * This function toggles active/inactive for content items * * @param id int id of content item to toggle * @param active string "true"/"false" * @return mixed true or Ajax error */ public function toggleContentState($args) { $this->checkAjaxToken(); $this->throwForbiddenUnless(SecurityUtil::checkPermission('Content::', '::', ACCESS_EDIT), LogUtil::getErrorMsgPermission()); $id = (int)$this->request->getPost()->get('id', -1); $active = $this->request->getPost()->get('active', null); if ($id == -1) { AjaxUtil::error(LogUtil::registerError($this->__('Error! No content ID passed.'))); } $ok = ModUtil::apiFunc('Content', 'Content', 'updateState', array('contentId' => $id, 'active' => $active)); if (!$ok) { AjaxUtil::error(LogUtil::registerError($this->__('Error! Could not update content item state.'))); } return new Zikula_Response_Ajax(array('id' => $id)); }
function wfBrowse($args) { global $wgAjaxCachePolicy, $wgUser, $wgContLang; // set cache policy $wgAjaxCachePolicy->setPolicy(0); // init vars $status = FTE_SUCCESS; $args = AjaxUtil::getArgs($args); $ns = @$args['ns']; $nsText = $wgContLang->getNsText($ns); $scope = @$args['scope']; $titleString = @$args['title']; $titleKey = @$args['title']; $dir = @$args['dir']; $prev = ''; $next = ''; $result = ''; // validate input arguments if ($scope != 'all' && !$wgUser->isLoggedIn()) { $status = FTE_NOT_LOGGED_IN; } if ($status == FTE_SUCCESS) { if ($titleString) { $title = Title::newFromText($titleString, $ns); if ($title) { $ns = $title->getNamespace(); $nsText = $title->getNsText(); $titleString = $title->getText(); $titleKey = $title->getDBkey(); } } // issue query $status = ftBrowseResults($scope, $ns, $titleKey, $dir, $cnt, $result); // if paging up and not enough results, start over from the beginning if ($status == FTE_SUCCESS && $dir == -1 && $cnt < 10) { $dir = 1; $titleKey = ''; $titleString = ''; $status = ftBrowseResults($scope, $ns, $titleKey, $dir, $cnt, $result); } } if ($status == FTE_SUCCESS) { if ($dir == -1) { if ($cnt == 11) { $prev = '1'; } $next = '1'; } else { if ($titleKey) { $prev = '1'; } if ($cnt == 11) { $next = '1'; } } } // return $titleString = StructuredData::escapeXml($titleString); return "<browse status=\"{$status}\" ns=\"{$ns}\" nsText=\"{$nsText}\" title=\"{$titleString}\" dir=\"{$dir}\" prev=\"{$prev}\" next=\"{$next}\">{$result}</browse>"; }
function wfAddGedcomSourceMatches($args) { global $wgUser, $wgAjaxCachePolicy, $wrBotUserID; // set cache policy $wgAjaxCachePolicy->setPolicy(0); $status = GE_SUCCESS; if (!$wgUser->isLoggedIn()) { $status = GE_NOT_LOGGED_IN; } else { if (wfReadOnly() || $wgUser->getID() != $wrBotUserID) { $status = GE_NOT_AUTHORIZED; } } $args = AjaxUtil::getArgs($args); if ($status == GE_SUCCESS) { $dbw =& wfGetDB(DB_MASTER); $dbw->ignoreErrors(true); $dbw->begin(); if ($args['author'] && $args['title']) { $stat = fgAddGedcomSourceMatch($dbw, $args['userID'], $args['author'] . $args['title'], 'AT', $args['pageTitle']); if ($stat != GE_SUCCESS) { $status = $stat; } } if ($args['author'] && $args['abbrev']) { $stat = fgAddGedcomSourceMatch($dbw, $args['userID'], $args['author'] . $args['abbrev'], 'AA', $args['pageTitle']); if ($stat != GE_SUCCESS) { $status = $stat; } } if ($args['title']) { $stat = fgAddGedcomSourceMatch($dbw, $args['userID'], $args['title'], 'T', $args['pageTitle']); if ($stat != GE_SUCCESS) { $status = $stat; } } if ($args['abbrev']) { $stat = fgAddGedcomSourceMatch($dbw, $args['userID'], $args['abbrev'], 'A', $args['pageTitle']); if ($stat != GE_SUCCESS) { $status = $stat; } } if ($status != GE_SUCCESS) { $dbw->rollback(); } else { $dbw->commit(); } } // return status return "<addGedcomSourceMatches status=\"{$status}\"/>"; }
public function change($args) { if (!SecurityUtil::checkPermission('IWusers::', '::', ACCESS_ADMIN)) { AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('Sorry! No authorization to access this module.'))); } $uid = FormUtil::getPassedValue('uid', -1, 'GET'); if ($uid == -1) AjaxUtil::error('no change user id'); // get user information $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $userAvatar = ModUtil::func('IWmain', 'user', 'getUserInfo', array('uid' => $uid, 'info' => 'na', 'sv' => $sv)); $toDo = FormUtil::getPassedValue('toDo', -1, 'GET'); if ($toDo == -1) AjaxUtil::error('no action defined'); $chid = '_' . $userAvatar; $error = ''; $path = ModUtil::getVar('IWmain', 'documentRoot') . '/' . ModUtil::getVar('IWusers', 'usersPictureFolder') . '/'; if ($toDo == 'del') { //delete the file if (!ModUtil::func('IWusers', 'user', 'deleteAvatar', array('avatarName' => substr($chid, 0, -4), 'extensions' => array('jpg', 'png', 'gif')))) { $error = $this->__('Error deleting avatar'); } //delete the small picture ModUtil::func('IWusers', 'user', 'deleteAvatar', array('avatarName' => substr($chid, 0, -4) . '_s', 'extensions' => array('jpg', 'png', 'gif'))); if (!ModUtil::apiFunc('IWusers', 'user', 'changeAvatar', array('avatar' => '', 'target' => 'newavatar', 'uid' => $uid, ))) $error = $this->__('Changing the avatar has failed.'); } else { $file_extension = strtolower(substr(strrchr($chid, "."), 1)); $formats = '$jpg$$png$$gif$'; $formats = str_replace('$' . $file_extension . '$', '', $formats); $len = strlen($formats) - 2; $formatsArray = explode('$$', substr($formats, 1, $len)); //change file name $changed = rename($path . $chid, $path . substr($chid, 1, strlen($chid))); if ($changed) { ModUtil::func('IWusers', 'user', 'deleteAvatar', array('avatarName' => substr($chid, 1, -4), 'extensions' => $formatsArray)); } else { $error = $this->__('Error changing avatar'); } //Change small pictures $chid_s = substr($chid, 0, -4) . '_s.' . $file_extension; rename($path . $chid_s, $path . substr($chid_s, 1, strlen($chid_s))); ModUtil::func('IWusers', 'user', 'deleteAvatar', array('avatarName' => substr($chid_s, 1, -4), 'extensions' => $formatsArray)); if (!ModUtil::apiFunc('IWusers', 'user', 'changeAvatar', array('avatar' => '', 'target' => 'newavatar', 'uid' => $uid, ))) $error = $this->__('Changing the avatar has failed.'); if (!ModUtil::apiFunc('IWusers', 'user', 'changeAvatar', array('avatar' => $userAvatar, 'uid' => $uid, ))) $error = $this->__('Changing the avatar has failed.'); } $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::func('IWmain', 'user', 'userSetVar', array('module' => 'IWmain_block_news', 'name' => 'have_news', 'value' => 'ch', 'sv' => $sv)); AjaxUtil::output(array('chid' => $userAvatar, 'error' => $error)); }
/** * Delete a topic * @author Albert Pérez Monfort (aperezm@xtec.cat) * @param: args Array with the topic id * @return true if the topic have been deleted */ public function deletetopic($args) { if (!SecurityUtil::checkPermission('IWnoteboard::', '::', ACCESS_ADMIN)) { AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('Sorry! No authorization to access this module.'))); } $tid = FormUtil::getPassedValue('tid', -1, 'GET'); if ($tid == -1) { LogUtil::registerError('no topic id'); AjaxUtil::output(); } // get a note information $topic = ModUtil::apiFunc('IWnoteboard', 'user', 'gettema', array('tid' => $tid)); if ($topic == false) { LogUtil::registerError('unable to get topic info for tid=' . DataUtil::formatForDisplay($tid)); AjaxUtil::output(); } $lid = ModUtil::apiFunc('IWnoteboard', 'admin', 'esborra', array('tid' => $tid)); if (!$lid) { AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('The action has failed'))); } else { // delete the record // Success $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); ModUtil::apiFunc('IWmain', 'user', 'usersVarsDelModule', array('name' => 'nbtopics', 'module' => 'IWnoteboard', 'sv' => $sv)); } AjaxUtil::output(array('tid' => $tid)); }