Example #1
0
 function simpledisplay($args)
 {
     // security check
     if (!SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_READ)) {
         return LogUtil::registerPermissionError();
     }
     $ot = FormUtil::getPassedValue('ot', isset($args['ot']) ? $args['ot'] : 'address', 'GET');
     $id = (int) FormUtil::getPassedValue('id', isset($args['id']) ? $args['id'] : null, 'GET');
     $category = FormUtil::getPassedValue('category', 0);
     $private = FormUtil::getPassedValue('private', 0);
     unset($args);
     $lang = ZLanguage::getLanguageCode();
     if (!$id) {
         return z_exit($this->__f('Error! Invalid id [%s] received.', $id));
     }
     // get the details
     $object = new AddressBook_DBObject_Address();
     $data = $object->get($id);
     // get the custom fields
     $cus_where = "";
     $cus_sort = "cus_pos ASC";
     $cus_Array = new AddressBook_DBObject_CustomfieldArray();
     $customfields = $cus_Array->get($cus_where, $cus_sort);
     foreach ($customfields as $key => $customfield) {
         if (isset($customfield['name1']) && $customfield['name1'] && $lang != 'en') {
             $customfields[$key]['name'] = $customfield['name1'];
         }
     }
     // Labels
     $addressbook_labels = DBUtil::selectObjectArray('addressbook_labels');
     $ablabels = array();
     foreach ($addressbook_labels as $addressbook_label) {
         if (isset($addressbook_label['name1']) && $addressbook_label['name1'] && $lang != 'en') {
             $addressbook_label['name'] = $addressbook_label['name1'];
         }
         $ablabels[$addressbook_label['id']] = $addressbook_label;
     }
     $this->view->assign('address', $data);
     $this->view->assign('customfields', $customfields);
     $this->view->assign('ot', $ot);
     $this->view->assign('category', $category);
     $this->view->assign('private', $private);
     $this->view->assign('preferences', ModUtil::getVar('AddressBook'));
     $this->view->assign('lang', $lang);
     $this->view->assign('ablabels', $ablabels);
     return $this->view->fetch('user_simpledisplay.tpl');
 }
Example #2
0
 /**
  * Clear cache for given item. Can be called from other modules to clear an item cache.
  *
  * @param $item - the item: array with data or id of the item
  */
 function clearItemCache($item)
 {
     if ($item && !is_array($item)) {
         $object = new AddressBook_DBObject_Address();
         $item = $object->get($item);
     }
     if ($item && isset($item['id']) && $item['id'] > 0) {
         // Clear View_cache
         $cache_ids = array();
         $cache_ids[] = 'display/id_' . $item['id'];
         $cache_ids[] = 'view/cat_0';
         $cache_ids[] = 'view/cat_' . $item['cat_id'];
         $view = Zikula_View::getInstance('AddressBook');
         foreach ($cache_ids as $cache_id) {
             $view->clear_cache(null, $cache_id);
         }
         // Clear Theme_cache
         $cache_ids = array();
         $cache_ids[] = 'AddressBook/user/display/id_' . $item['id'];
         // for given Id, according to new cache_id structure in Zikula 1.3.2.dev (1.3.3)
         //$cache_ids[] = 'homepage'; // for homepage (it can be adjustment in module settings)
         $cache_ids[] = 'AddressBook/user/view';
         // view function (contacts list)
         $cache_ids[] = 'AddressBook/user/main';
         // main function
         $theme = Zikula_View_Theme::getInstance();
         //if (Zikula_Core::VERSION_NUM > '1.3.2') {
         if (method_exists($theme, 'clear_cacheid_allthemes')) {
             $theme->clear_cacheid_allthemes($cache_ids);
         } else {
             // clear cache for current theme only
             foreach ($cache_ids as $cache_id) {
                 $theme->clear_cache(null, $cache_id);
             }
         }
     }
 }