Exemplo n.º 1
0
 /**
  * buildAcl
  * @param Model_Users $objModelUsers
  * @return void
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function buildAcl(Model_Users $objModelUsers)
 {
     try {
         foreach (self::$arrZones as $arrZone) {
             $this->arrZoneAcls['id_' . $arrZone['id']] = new Acl();
         }
         /**
          * add groups
          */
         $arrGroups = $objModelUsers->getGroups();
         foreach ($arrGroups as $objGroup) {
             foreach (self::$arrZones as $arrZone) {
                 if (!$this->arrZoneAcls['id_' . $arrZone['id']]->hasRole($objGroup->key)) {
                     $this->arrZoneAcls['id_' . $arrZone['id']]->addRole(new Zend_Acl_Role($objGroup->key));
                 }
             }
         }
         /**
          * add resources & groups & privileges
          */
         $arrResources = $objModelUsers->getResourcesGroups();
         foreach ($arrResources as $objResource) {
             if (!$this->arrZoneAcls['id_' . self::ZONE_ZOOLU]->has($objResource->key)) {
                 $this->arrZoneAcls['id_' . self::ZONE_ZOOLU]->add(new Zend_Acl_Resource($objResource->key));
             }
             $this->arrZoneAcls['id_' . self::ZONE_ZOOLU]->allow($objResource->groupKey, $objResource->key, $objResource->permissionTitle);
         }
     } catch (Exception $exc) {
         Zend_Registry::get('Core')->logger->err($exc);
     }
 }
Exemplo n.º 2
0
 public function callback_facebookAction()
 {
     $this->noViewRenderer(true);
     $request = $this->getRequest();
     $facebook = new WM_Facebook_Api(array('appId' => JO_Registry::forceGet('facebook_appid'), 'secret' => JO_Registry::forceGet('facebook_secret')));
     $fbData = $facebook->api('/me');
     if ($fbData['verified'] == 'true' && isset($fbData['id'])) {
         $user = Model_Users::getFBuser($fbData['id']);
         if ($user) {
             $user['following'] = Model_Users::getFollowers($user['user_id']);
             $groups = unserialize($user['groups']);
             if (is_array($groups) and count($groups) > 1) {
                 unset($user['groups']);
                 $fetch_all = Model_Users::getGroups($groups);
                 $user['access'] = array();
                 if ($fetch_all) {
                     foreach ($fetch_all as $row) {
                         $modules = unserialize($row['rights']);
                         if (is_array($modules)) {
                             foreach ($modules as $module => $ison) {
                                 $result['access'][$module] = $module;
                             }
                         }
                     }
                 }
             }
             if (isset($user['access']) && count($user['access'])) {
                 $user['is_admin'] = true;
             }
             JO_Session::set($user);
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=dashboard'));
         } else {
             $userData = array('fb_id' => $fbData['id'], 'firstname' => $fbData['first_name'], 'lastname' => $fbData['last_name'], 'email' => $fbData['email'], 'email_confirm' => $fbData['email'], 'username' => $fbData['username']);
             JO_Session::set('fb_data', $userData);
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=registration'));
         }
     } else {
         JO_Session::set('msg_error', $this->translate('Facebook login error. Please try again later.'));
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
     }
 }
Exemplo n.º 3
0
 public function indexAction()
 {
     $this->noViewRenderer(true);
     $request = $this->getRequest();
     if ($request->getQuery('openId') && strlen($request->getQuery('openId')) == 32 && $request->getServer('HTTP_REFERER')) {
         $referer = str_replace('www.', '', JO_Validate::validateHost($request->getServer('HTTP_REFERER')));
         $domain = $request->getDomain();
         if ($referer && $referer != $domain && self::allowledReferal($referer)) {
             //check user
             if ($result = Model_Extensions_Singlesignon::checkUser($referer, $domain, $request->getQuery('openId'))) {
                 if ($result && $result['status'] == 'activate') {
                     $groups = unserialize($result['groups']);
                     if (is_array($groups) and count($groups) > 1) {
                         unset($result['groups']);
                         $fetch_all = Model_Users::getGroups($groups);
                         $result['access'] = array();
                         if ($fetch_all) {
                             foreach ($fetch_all as $row) {
                                 $modules = unserialize($row['rights']);
                                 if (is_array($modules)) {
                                     foreach ($modules as $module => $ison) {
                                         $result['access'][$module] = $module;
                                     }
                                 }
                             }
                         }
                     }
                     if (isset($result['access']) && count($result['access'])) {
                         $result['is_admin'] = true;
                     }
                     JO_Session::set($result);
                 }
             } elseif (!JO_Session::get('user_id')) {
                 $url = 'http://' . $referer . '/public/extensions_singlesignon/getUserData/?openId=' . $request->getQuery('openId') . '&referer=' . $referer . '&domain=' . $domain;
                 if (ini_get('allow_url_fopen')) {
                     $response = file_get_contents($url);
                 } elseif (function_exists('curl_init')) {
                     $response = $this->file_get_contents_curl($url);
                 }
                 if ($response) {
                     $response = JO_Json::decode(JO_Encrypt_Md5::decrypt($response, $domain), true);
                     //register user
                     if ($response && is_array($response)) {
                         if ($result = Model_Extensions_Singlesignon::createUser($response)) {
                             $groups = self::mb_unserialize($result['groups']);
                             if (is_array($groups) and count($groups) > 1) {
                                 unset($result['groups']);
                                 $fetch_all = Model_Users::getGroups($groups);
                                 $result['access'] = array();
                                 if ($fetch_all) {
                                     foreach ($fetch_all as $row) {
                                         $modules = self::mb_unserialize($row['rights']);
                                         if (is_array($modules)) {
                                             foreach ($modules as $module => $ison) {
                                                 $result['access'][$module] = $module;
                                             }
                                         }
                                     }
                                 }
                             }
                             if (isset($result['access']) && count($result['access'])) {
                                 $result['is_admin'] = true;
                             }
                             JO_Session::set($result);
                         }
                     }
                 }
             }
         }
         $this->redirect($request->getBaseUrl());
     }
     $this->view->single_sign_on = array();
     $single_sign_on = WM_Store::getSettingsPairs(array('filter_group' => 'single_sign_on'));
     $model_images = new Model_Images();
     $sort_order = array();
     foreach ($single_sign_on as $row => $data) {
         $sort_order[$row] = isset($data['sort_order']) ? $data['sort_order'] : 0;
         if ($data['site_logo'] && file_exists(BASE_PATH . '/uploads/' . $data['site_logo'])) {
             $data['preview'] = 'uploads/' . $data['site_logo'];
         } else {
             $data['preview'] = '';
         }
         $data['preview'] = $model_images->resize($data['site_logo'], 140, 30);
         $data['href'] = 'http://' . $data['url'] . '/public/';
         if (JO_Registry::get('singlesignon_enable_login') && JO_Session::get('user_id')) {
             $data['href'] .= '?openId=' . md5($request->getDomain() . $data['url'] . JO_Session::get('username') . JO_Session::get('email'));
         }
         $this->view->single_sign_on[$row] = $data;
     }
     array_multisort($sort_order, SORT_ASC, $this->view->single_sign_on);
     if (JO_Registry::get('singlesignon_enable_dropdown') && count($this->view->single_sign_on)) {
         $this->view->ext_css = WM_Router::create($request->getBaseUrl() . '?controller=cache&extension=singlesignon&action=css&setFile=css.css');
         $this->view->ext_js = WM_Router::create($request->getBaseUrl() . '?controller=cache&extension=singlesignon&action=js&setFile=js.js');
         $this->getLayout()->placeholder('singlesignon', $this->view->render('index', 'extensions_singlesignon'));
     }
 }