Example #1
0
 /**
  * Display hook for edit views.
  *
  * Subject is the object being created/edited that we're attaching to.
  * args[id] Is the ID of the subject.
  * args[caller] the module who notified of this event.
  *
  * @param Zikula_DisplayHook $hook The hookable event.
  *
  * @return void
  */
 public function ui_edit(Zikula_DisplayHook $hook)
 {
     // security check - return void if not allowed.
     $module = $hook->getCaller();
     $id = $hook->getId();
     if (!$this->validation) {
         // since no validation object exists, this is the first time display of the create/edit form.
         // either display an empty form, for a create action, or query the database for a exiting object.
         if (!$id) {
             // this is a create action so create a new empty object for editing
             $comments = array('id' => null, 'commenttext' => '');
         } else {
             // this is an edit action so we need to get the data from the DB for editing
             $comments = get_comment_from_db("where id = {$id} AND module = {$module}");
             // fake database call
         }
     } else {
         // this is a re-entry because the form didn't validate.
         // We need to gather the input from the form and render display
         // get the input from the form (this was populated by the validation hook).
         $comments = $this->validation->getObject();
     }
     // create a view and assign data for display
     $view = Zikula_View::getInstance('Comments');
     $view->assign('hook_comments', $comments);
     // add this response to the event stack
     $response = new Zikula_Response_DisplayHook($name, $view, "areaname_ui_edit.tpl");
     $hook->setResponse($response);
 }
Example #2
0
 /**
  * Display hook for view.
  *
  * @param Zikula_Hook $hook The hook.
  *
  * @return void
  */
 public function uiView(Zikula_DisplayHook $hook)
 {
     // Input from the hook
     $callermodname = $hook->getCaller();
     $callerobjectid = $hook->getId();
     // Check permissions
     if (!SecurityUtil::checkPermission('Ephemerides::', "::", ACCESS_READ)) {
         return;
     }
     // Get items
     $items = ModUtil::apiFunc('Ephemerides', 'user', 'gettoday', $args);
     // create the output object
     $view = Zikula_View::getInstance('Ephemerides', false, null, true);
     $view->assign('areaid', $hook->getAreaId());
     $view->assign('items', $items);
     $template = 'ephemerides_user_display.tpl';
     // Add style
     PageUtil::addVar('stylesheet', 'modules/Ephemerides/style/style.css');
     $response = new Zikula_Response_DisplayHook('provider.ephemerides.ui_hooks.ephemeride', $view, $template);
     $hook->setResponse($response);
 }
Example #3
0
 /**
  * Display smilies and provide interface for their use in an edit object form
  * 
  * @param Zikula_DisplayHook $hook
  */
 public function uiEdit(Zikula_DisplayHook $hook)
 {
     // some initialization stuff
     $assign = isset($params['assign']) && !empty($params['assign']) ? $params['assign'] : 'smilies';
     $type = isset($params['type']) && !empty($params['type']) ? $params['type'] : '';
     $active_smilies = array();
     $smilies = array();
     // Get all Smilies
     $all_smilies = ModUtil::getVar('BBSmile', 'smilie_array');
     foreach ($all_smilies as $key => $smilie) {
         // Check if the type of the smilie is the wanted type
         if ($smilie['active'] == 1) {
             $active_smilies[$key] = $smilie;
         }
     }
     // if there is no type then return all active smilies
     if ($type == '') {
         $smilies = $active_smilies;
     } else {
         // Get only the smilies with the wanted type
         // map words to number
         if ($type == 'standard') {
             $type = 0;
         } else {
             // eg. $type == "auto" or all other values
             $type = 1;
         }
         foreach ($active_smilies as $key => $smilie) {
             // Check if the typ od the smilie is the wanted type and if the smilie is active
             if ($smilie['type'] == $type && $smilie['active'] == 1) {
                 $smilies[$key] = $smilie;
             }
         }
     }
     // Asign the smilies to smarty
     $this->view->assign($assign, $smilies);
     $this->view->assign($assign . '_count', count($smilies));
     $hook->setResponse(new Zikula_Response_DisplayHook(BBSmile_Version::PROVIDER_UIAREANAME, $this->view, 'hook/display_bbsmiles.tpl'));
 }
Example #4
0
    /**
     * Display a html snippet with buttons for inserting Scribites into a textarea
     *
     * @param Zikula_Hook $hook
     *
     * @return void
     */
    public function uiEdit(Zikula_DisplayHook $hook)
    {
        // get the module name
        $module = $hook->getCaller();

        // Security check if user has COMMENT permission for scribite
        if (!SecurityUtil::checkPermission('Scribite::', "$module::", ACCESS_COMMENT)) {
            return;
        }

        // load the editor
        $scribiteheader = $this->loader(array(
            'modulename' => $module));

        // add the scripts to page header
        if ($scribiteheader) {
            PageUtil::AddVar('header', $scribiteheader);
        }

        $response = new Zikula_Response_DisplayHook(Scribite_Version::PROVIDER_UIAREANAME, $this->view, 'hook/scribite.tpl');
        $hook->setResponse($response);
    }
Example #5
0
 /**
  * Display hook for view.
  *
  * Subject is the object being viewed that we're attaching to.
  * args[id] Is the id of the object.
  * args[caller] the module who notified of this event.
  *
  * @param Zikula_Hook $hook The hook.
  *
  * @return void
  */
 public function uiView(Zikula_DisplayHook $hook)
 {
     // work out the input from the hook
     $mod = $hook->getCaller();
     $areaId = $hook->getAreaId();
     $objectid = $hook->getId();
     // first check if the user is allowed to do any comments for this module/objectid
     if (!SecurityUtil::checkPermission('EZComments::', "{$mod}:{$objectid}:", ACCESS_OVERVIEW)) {
         return;
     }
     $subject = array();
     //$hook->getSubject();
     $owneruid = isset($subject['cr_uid']) ? (int) $subject['cr_uid'] : 0;
     $useurl = isset($subject['useurl']) ? $subject['useurl'] : null;
     $ownerUidSession = SessionUtil::delVar('commentOwner', 0);
     if ($ownerUidSession > 0) {
         $owneruid = $ownerUidSession;
     }
     // we may have a comment incoming
     $ezcomment = unserialize(SessionUtil::getVar('ezcomment', 'a:0:{}'));
     $ezcomment = isset($ezcomment[$mod][$objectid]) ? $ezcomment[$mod][$objectid] : null;
     // we may get some input in from the navigation bar
     $order = FormUtil::getPassedValue('order');
     $sortorder = $order == 1 ? 'DESC' : 'ASC';
     $status = 0;
     // check if we're using the pager
     $enablepager = ModUtil::getVar('EZComments', 'enablepager');
     if ($enablepager) {
         $numitems = ModUtil::getVar('EZComments', 'commentsperpage');
         $startnum = FormUtil::getPassedValue('comments_startnum');
         if (!isset($startnum) && !is_numeric($startnum)) {
             $startnum = -1;
         }
     } else {
         $startnum = -1;
         $numitems = -1;
     }
     $params = compact('mod', 'areaId', 'objectid', 'sortorder', 'status', 'numitems', 'startnum');
     $items = ModUtil::apiFunc('EZComments', 'user', 'getall', $params);
     if ($items === false) {
         return LogUtil::registerError($this->__('Internal Error.'), null, 'index.php');
     }
     $items = ModUtil::apiFunc('EZComments', 'user', 'prepareCommentsForDisplay', $items);
     if ($enablepager) {
         $commentcount = ModUtil::apiFunc('EZComments', 'user', 'countitems', compact('mod', 'objectid', 'status'));
     } else {
         $commentcount = count($items);
     }
     // create the output object
     $view = Zikula_View::getInstance('EZComments', false, null, true);
     $view->assign('areaid', $areaId)->assign('comments', $items)->assign('commentcount', $commentcount)->assign('ezcomment', $ezcomment)->assign('ezc_info', compact('mod', 'objectid', 'sortorder', 'status'))->assign('modinfo', ModUtil::getInfo(ModUtil::getIdFromName($mod)))->assign('msgmodule', System::getVar('messagemodule', ''))->assign('prfmodule', System::getVar('profilemodule', ''))->assign('allowadd', SecurityUtil::checkPermission('EZComments::', "{$mod}:{$objectid}:", ACCESS_COMMENT))->assign('loggedin', UserUtil::isLoggedIn());
     $modUrl = $hook->getUrl();
     $redirect = !is_null($modUrl) ? $modUrl->getUrl() : '';
     $view->assign('returnurl', $redirect);
     // encode the url - otherwise we can get some problems out there....
     $redirect = base64_encode($redirect);
     $view->assign('redirect', $redirect);
     $view->assign('objectid', $objectid);
     // assign the user is of the content owner
     $view->assign('owneruid', $owneruid);
     // assign url that should be stored in db and sent in email if it
     // differs from the redirect url
     $view->assign('useurl', $useurl);
     // flag to recognize the main call
     static $mainScreen = true;
     $view->assign('mainscreen', $mainScreen);
     $mainScreen = false;
     // assign the values for the pager
     $view->assign('ezc_pager', array('numitems' => $commentcount, 'itemsperpage' => $numitems));
     // find out which template and stylesheet to use
     $templateset = isset($args['template']) ? $args['template'] : FormUtil::getPassedValue('eztpl');
     $css = isset($args['ezccss']) ? $args['ezccss'] : FormUtil::getPassedValue('ezccss');
     $defaultcss = ModUtil::getVar('EZComments', 'css', 'style.css');
     if (!$view->template_exists(DataUtil::formatForOS($templateset) . '/ezcomments_user_view.tpl')) {
         $templateset = ModUtil::getVar('EZComments', 'template', 'Standard');
     }
     $view->assign('template', $templateset);
     // include stylesheet if there is a style sheet
     $css = $css ? "{$css}.css" : $defaultcss;
     if ($css = ModUtil::apiFunc('EZComments', 'user', 'getStylesheet', array('path' => "{$templateset}/{$css}"))) {
         PageUtil::addVar('stylesheet', $css);
     }
     $template = DataUtil::formatForOS($templateset) . '/ezcomments_user_view.tpl';
     $response = new Zikula_Response_DisplayHook('provider_area.ui_hooks.ezcomments.comments', $view, $template);
     $hook->setResponse($response);
 }