Beispiel #1
0
    /**
     * 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));
    }
Beispiel #2
0
    /**
     * Change the characteristics of a forum definition
     * @author:     Albert Pï¿œrez Monfort (aperezm@xtec.cat)
     * @param:	args   Array with the id of the forum and the value to change
     * @return:	the new value in database
     */
    public function modifyForum($args) {
        if (!SecurityUtil::checkPermission('IWforums::', '::', ACCESS_ADMIN)) {
            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'));
        }

        $char = $this->request->getPost()->get('character', '');
        if (!$char) {
            throw new Zikula_Exception_Fatal($this->__('no char defined'));
        }

        //Get agenda information
        $item = ModUtil::apiFunc('IWforums', 'user', 'get',
                                  array('fid' => $fid));
        if ($item == false) {
            AjaxUtil::error(DataUtil::formatForDisplayHTML($this->__('Forum not found')));
        }

        $value = ($item[$char]) ? 0 : 1;

        //change value in database
        $items = array($char => $value);

        if (!ModUtil::apiFunc('IWforums', 'admin', 'update',
                               array('fid' => $fid,
                    'items' => $items))) {
            LogUtil::registerError($this->__('Error'));
            AjaxUtil::output();
        }

        return new Zikula_Response_Ajax(array('fid' => $fid,
                ));
    }
Beispiel #3
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));
 }
Beispiel #4
0
    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));
    }
Beispiel #5
0
    /**
     * 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));
    }