예제 #1
0
파일: joaktree.php 프로젝트: Lothurm/J3.x
 public function setCookie()
 {
     static $indOneTime;
     if (isset($indOneTime) && $indOneTime) {
         return true;
     }
     // set up cookie
     $params = JoaktreeHelper::getJTParams();
     $indCookie = $params->get('indCookies', true);
     if ($indCookie) {
         // we fetch the cookie
         $cookie = new JInputCookie();
         $tmp = $cookie->get('jt_last_persons', '', 'string');
         // prepare the array
         if ($tmp) {
             $personList = (array) json_decode(base64_decode($tmp));
         } else {
             $personList = array();
         }
         // check whether this person is already in array
         $person =& $this->getPerson();
         $value = $person->app_id . '!' . $person->id . '!' . $person->tree_id;
         if (in_array($value, $personList)) {
             // loop through array and move person to first position
             $newList = array();
             $newList[] = $value;
             foreach ($personList as $item) {
                 if ($item != $value) {
                     $newList[] = $item;
                 }
             }
         } else {
             // place the first person to start of array
             $newList = $personList;
             array_unshift($newList, $value);
         }
         // if the array is too big, remove the last person
         if (count($newList) > 10) {
             array_pop($newList);
         }
         // and store the new cookie
         //$expire = mktime().time()+60*60*24*180;
         $expire = time() + 60 * 60 * 24 * 180;
         $cookie->set('jt_last_persons', base64_encode(json_encode($newList)), $expire, '/');
     }
     $indOneTime = true;
     return true;
 }
예제 #2
0
 private function _buildContentWhere()
 {
     $app = JFactory::getApplication('site');
     // always from the request
     $tmp = $app->input->get('filter', null, 'string');
     // if nothing found, check the cookie -- only when we use cookies
     if (!isset($tmp)) {
         $params = $app->getParams();
         if ($params->get('indCookies', true)) {
             $cookie = new JInputCookie();
             $tmp = $cookie->get('jt_nam_index', 0, 'int');
         }
     }
     // if nothing found, we use 0
     $filterId = !isset($tmp) ? 0 : (int) $tmp;
     $index = $this->getNameIndex();
     $filters = $index[$filterId];
     // done with filter for index
     $wheres = array();
     $treeId = intval($this->getTreeId());
     $wheres[] = 'jpn.familyName <> ' . $this->_db->quote('') . ' ';
     if ($treeId) {
         $wheres[] = 'jtp.tree_id = ' . $treeId;
         $wheres[] = 'jte.access IN ' . JoaktreeHelper::getUserAccessLevels();
     }
     if ($filters) {
         $wheres[] = count($filters) == 1 ? ' jpn.indexNam =  "' . array_shift($filters) . '" ' : ' jpn.indexNam IN ("' . implode('","', $filters) . '" ) ';
     }
     return $wheres;
 }
예제 #3
0
파일: locations.php 프로젝트: Lothurm/J3.x
 private function _buildContentWhere()
 {
     $app = JFactory::getApplication('site');
     // always from the request
     $tmp = $app->input->get('filter', null, 'string');
     // if nothing found, check the cookie -- only when we use cookies
     if (!isset($tmp)) {
         $params = $app->getParams();
         if ($params->get('indCookies', true)) {
             $cookie = new JInputCookie();
             $tmp = $cookie->get('jt_loc_index', 0, 'int');
         }
     }
     // if nothing found, we use 0
     $filterId = !isset($tmp) ? 0 : (int) $tmp;
     $index = $this->getLocationIndex();
     $filters = $index[$filterId];
     $wheres = array();
     $wheres[] = ' jln.indDeleted = 0 ';
     if ($filters) {
         $wheres[] = count($filters) == 1 ? ' jln.indexLoc =  "' . array_shift($filters) . '" ' : ' jln.indexLoc IN ("' . implode('","', $filters) . '" ) ';
     }
     return $wheres;
 }
예제 #4
0
파일: helper.php 프로젝트: Lothurm/J3.x
 function getTechnology()
 {
     static $_technology;
     $app = JFactory::getApplication('site');
     $input = $app->input;
     $params = $app->getParams();
     $indCookie = $params->get('indCookies', true);
     if ($indCookie) {
         $cookie = new JInputCookie();
     }
     // use cookies
     if (!isset($_technology)) {
         // Find the value for tech - first from the cookie when cookies are used
         if ($indCookie) {
             $tmp = $cookie->get('tech');
         }
         if (!isset($tmp)) {
             // if not found in cookie -> look in url
             $tmp = $input->get('tech');
         }
         if (!isset($tmp)) {
             // if not found in url -> set default value of 'a'
             $_technology = 'a';
         } else {
             if ($tmp != 'a' and $tmp != 'j' and $tmp != 'b') {
                 // if technology is wrong value -> set default value of 'a'
                 $_technology = 'a';
             } else {
                 $_technology = $tmp;
             }
         }
     }
     if ($indCookie) {
         // set up a cookie for non default value
         if ($_technology != 'a') {
             //set a cookie for 1 hour = 3600 seconds
             $expire = time() + 60 * 60;
             //setcookie("tech", $_technology, time()+3600, "/","", 0);
         } else {
             //delete cookie by setting 1 hour (= 3600 seconds) in the past
             $expire = time() - 60 * 60;
             //setcookie("tech", $_technology, time()-3600, "/","", 0);
         }
         $cookie->set('tech', $_technology, $expire, '/');
     }
     return $_technology;
 }
예제 #5
0
파일: helper.php 프로젝트: Lothurm/J3.x
 public static function getList($numberInList)
 {
     // get cookie
     $params = JComponentHelper::getParams('com_joaktree');
     $indCookie = $params->get('indCookies', false);
     if (!$indCookie) {
         return false;
     }
     // array to return
     $person = array();
     // we fetch the cookie
     $cookie = new JInputCookie();
     $tmp = $cookie->get('jt_last_persons', '', 'string');
     // prepare the array
     if ($tmp) {
         $cookieList = (array) json_decode(base64_decode($tmp));
     } else {
         $cookieList = array();
     }
     if (count($cookieList)) {
         $db = JFactory::getDBO();
         $query = $db->getQuery(true);
         // get user access info
         $levels = JoaktreeHelper::getUserAccessLevels();
         // set up maximum number of items
         $maxItem = count($cookieList) > $numberInList ? $numberInList : count($cookieList);
         // get menuId & technology
         $menus = JoaktreeHelper::getMenus('joaktree');
         $linkBase = 'index.php?option=com_joaktree&view=joaktree';
         for ($i = 0; $i < $maxItem; $i++) {
             $query->clear();
             // item is a string separated by !: app_id, person_id, tree_id;
             $elements = explode('!', array_shift($cookieList));
             // retrieve person
             $app_id = array_shift($elements);
             $person_id = array_shift($elements);
             $tree_id = array_shift($elements);
             if (!empty($app_id) && !empty($person_id) && !empty($tree_id)) {
                 $query->select(JoaktreeHelper::getConcatenatedFullName() . ' AS fullName ');
                 $query->from(' #__joaktree_persons   jpn ');
                 $query->where(' jpn.app_id    = ' . $app_id . ' ');
                 $query->where(' jpn.id        = ' . $db->Quote($person_id) . ' ');
                 // join with admin persons
                 $query->innerJoin(JoaktreeHelper::getJoinAdminPersons(true));
                 // join with trees
                 $query->innerJoin(' #__joaktree_tree_persons  jtp ' . ' ON (   jtp.app_id    = jpn.app_id ' . '    AND jtp.person_id = jpn.id ' . '    AND jtp.tree_id   = ' . $tree_id . ' ' . '    ) ');
                 $query->innerJoin(' #__joaktree_trees         jte ' . ' ON (   jte.app_id    = jtp.app_id ' . '    AND jte.id        = jtp.tree_id ' . '    AND jte.published = true ' . '    AND jte.access    IN ' . $levels . ' ' . '    ) ');
                 // fetch from database
                 $db->setQuery($query);
                 $tmpPerson = $db->loadObject();
                 if ($tree_id && isset($menus[$tree_id])) {
                     $menuItemId = $menus[$tree_id];
                     $tmpPerson->route = JRoute::_($linkBase . '&Itemid=' . $menuItemId . '&treeId=' . $tree_id . '&personId=' . $app_id . '!' . $person_id);
                     $tmpPerson->robot = '';
                 } else {
                     $tmpPerson->route = 0;
                     $tmpPerson->robot = '';
                 }
                 if (!empty($tmpPerson->fullName)) {
                     $person[] = $tmpPerson;
                 }
                 unset($tmpPerson);
             }
         }
     }
     return $person;
 }