예제 #1
0
 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));
 }
예제 #2
0
파일: Ajax.php 프로젝트: projectesIF/Sirius
    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,
                ));
    }
예제 #3
0
파일: pnajax.php 프로젝트: ro0f/Mediashare
/**
 * 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);
}
예제 #4
0
파일: Ajax.php 프로젝트: projectesIF/Sirius
    /**
     * 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));
    }
예제 #5
0
파일: Ajax.php 프로젝트: projectesIF/Sirius
    /**
     * 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));
    }
예제 #6
0
 /**
  * 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);
 }
예제 #7
0
파일: Ajax.php 프로젝트: projectesIF/Sirius
    /**
     * 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,
                ));
    }
예제 #8
0
 /**
  * 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.'));
 }
예제 #9
0
 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));
 }
예제 #10
0
파일: Ajax.php 프로젝트: projectesIF/Sirius
	/**
     * 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));
    }
예제 #11
0
파일: Ajax.php 프로젝트: projectesIF/Sirius
    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));
    }
예제 #12
0
파일: Ajax.php 프로젝트: projectesIF/Sirius
    /**
     * 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));
    }