Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 3
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);
    }
Esempio n. 4
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);
 }