Beispiel #1
0
 /**
  * Returns the site secret.
  *
  * Used to generate difficult to guess hashes for sessions and action tokens.
  *
  * @param bool $raw If true, a binary key will be returned
  *
  * @return string Site secret.
  * @access private
  */
 function get($raw = false)
 {
     if ($this->test_secret) {
         $secret = $this->test_secret;
     } else {
         $secret = $this->configTable->get('__site_secret__');
     }
     if (!$secret) {
         $secret = $this->init();
     }
     if ($raw) {
         // try to return binary key
         if ($secret[0] === 'z') {
             // new keys are "z" + base64URL
             $base64 = strtr(substr($secret, 1), '-_', '+/');
             $key = base64_decode($base64);
             if ($key !== false) {
                 // on failure, at least return string key :/
                 return $key;
             }
         } else {
             // old keys are hex
             return hex2bin($secret);
         }
     }
     return $secret;
 }
 /**
  * @param  $filterChain
  * @contextValues
  *  - fbSession (session from Facebook)
  *  -
  * @userValues
  *  - fbuser (user uid)
  *  - me. + $fbuser - user graph /me
  */
 public function execute($filterChain)
 {
     $configFromBase = ConfigTable::getInstance()->findAll();
     if ($configFromBase) {
         foreach ($configFromBase->toArray() as $option) {
             sfConfig::set('conf_' . $option['name'], $option['value']);
         }
     }
     header('P3P: CP="HONK"');
     // Execute this filter only once
     if (!$this->isFirstCall()) {
         $filterChain->execute();
         return;
     }
     $context = $this->getContext();
     $this->user = $context->getUser();
     $this->response = $context->getResponse();
     $this->request = $context->getRequest();
     $context->getConfiguration()->loadHelpers('Url');
     $this->user->setCulture('pl_PL');
     if ($this->request->hasParameter('signed_request')) {
         $this->user->setAttribute('signed_request', $this->request->getParameter('signed_request'), 'signed_request');
     }
     $facebook = FacebookService::getFacebook();
     $session = $facebook->getSession();
     $nextLink = $this->_generateNextLink($context->getConfiguration()->getApplication());
     $loginUrl = $facebook->getLoginUrl(array('canvas' => 1, 'fbconnect' => 0, 'req_perms' => sfConfig::get('app_facebook_permissions'), 'next' => $nextLink));
     if (!$session) {
         if ($this->request->isXMLHttpRequest()) {
             $context->getResponse()->setHttpHeader("Content-Type", "application/json; charset=utf-8");
             echo json_encode(array('status' => 200, 'redirect' => $loginUrl));
             exit;
         } else {
             $this->_redirectToFacebook($loginUrl);
         }
     }
     $context->set('fbSession', $session);
     $fbuser = $facebook->getUser();
     $this->user->setAttribute('fbuser', $fbuser);
     if (!$this->user->hasAttribute('me.' . $fbuser)) {
         try {
             $me = $facebook->api('/me');
             $this->_saveUserData($facebook, $me);
             $this->user->setAttribute('me.' . $fbuser, $me);
         } catch (FacebookApiException $e) {
             $log = LogsService::getInstance($e);
             $log->fromArray(array('user_id' => $fbuser, 'type' => 'FacebookApi', 'message' => 'Problem with get ME from FB Api'));
             $log->save();
         }
     } else {
         $this->getContext()->set('userFromBase', Doctrine_Query::create()->from('Users u')->select('u.*')->where('u.id = ?', $fbuser)->fetchOne());
     }
     $this->userFromBase = $this->getContext()->get('userFromBase');
     $this->_controlAccess($this->user->getAttribute('me.' . $fbuser));
     $filterChain->execute();
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function execute($request)
 {
     sfContext::getInstance()->getConfiguration()->loadHelpers('Url');
     $this->setTimeForm = new setTimeForm();
     $this->configStartTime = ConfigTable::getInstance()->findOneByName('startTime');
     if (!$this->configStartTime) {
         $this->configStartTime = new Config();
         $this->setTimeForm->setDefault('start_time', time());
     } else {
         $this->setTimeForm->setDefault('start_time', strtotime($this->configStartTime->value));
     }
     $this->configEndTime = ConfigTable::getInstance()->findOneByName('endTime');
     if (!$this->configEndTime) {
         $this->configEndTime = new Config();
         $this->setTimeForm->setDefault('end_time', strtotime('+15 day'));
     } else {
         $this->setTimeForm->setDefault('end_time', strtotime($this->configEndTime->value));
     }
     if ($this->getRequest()->hasParameter(get_class($this->setTimeForm))) {
         $this->setTimeForm->bind($this->getRequest()->getParameter(get_class($this->setTimeForm)));
         if ($this->setTimeForm->isValid()) {
             $this->configStartTime = ConfigTable::getInstance()->findOneByName('startTime');
             if (!$this->configStartTime) {
                 $this->configStartTime = new Config();
             }
             $this->configStartTime->fromArray(array('name' => 'startTime', 'value' => $this->setTimeForm->getValue('start_time')));
             $this->configStartTime->save();
             $this->configEndTime = ConfigTable::getInstance()->findOneByName('endTime');
             if (!$this->configEndTime) {
                 $this->configEndTime = new Config();
             }
             $this->configEndTime->fromArray(array('name' => 'endTime', 'value' => $this->setTimeForm->getValue('end_time')));
             $this->configEndTime->save();
             $this->getUser()->setFlash('setTime', true);
             $this->redirect(url_for2('default', array('module' => 'days', 'action' => 'index'), true));
         }
     }
 }
	/**
	 * This function runs all the table that uses the system default language
	 * Particular for 1.6.1, since 1.6 didn't convret all table
	 */
	function convertTableBySysDefault_161(){
		global $errors;

		$temp_table = new AdminsTable($this->table_prefix, 'admins', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'admins was not converted.';
			$_SESSION['redo_conversion'][$course_title]['AdminsTable'] = array($this->table_prefix, 'admins', $this->sys_default_lang, $course_id);
		}

		$temp_table = new AdminLogTable($this->table_prefix, 'admin_log', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'admin_log was not converted.';
			$_SESSION['redo_conversion'][$course_title]['AdminLogTable'] = array($this->table_prefix, 'admin_log', $this->sys_default_lang, $course_id);
		}

		$temp_table = new AutoEnrollTable($this->table_prefix, 'auto_enroll', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'auto_enroll was not converted.';
			$_SESSION['redo_conversion'][$course_title]['AutoEnrollTable'] = array($this->table_prefix, 'auto_enroll', $this->sys_default_lang, $course_id);
		}

		$temp_table = new AutoEnrollCoursesTable($this->table_prefix, 'auto_enroll_courses', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'auto_enroll_courses was not converted.';
			$_SESSION['redo_conversion'][$course_title]['AutoEnrollCourses'] = array($this->table_prefix, 'auto_enroll_courses', $this->sys_default_lang, $course_id);
		}

		$temp_table = new ConfigTable($this->table_prefix, 'config', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'config was not converted.';
			$_SESSION['redo_conversion'][$course_title]['ConfigTable'] = array($this->table_prefix, 'config', $this->sys_default_lang, $course_id);
		}

		$temp_table = new CourseAccessTable($this->table_prefix, 'course_access', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'course_access was not converted.';
			$_SESSION['redo_conversion'][$course_title]['CourseAccessTable'] = array($this->table_prefix, 'course_access', $this->sys_default_lang, $course_id);
		}

		$temp_table = new CourseStatsTable($this->table_prefix, 'course_stats', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'course_stats was not converted.';
			$_SESSION['redo_conversion'][$course_title]['CourseStatsTable'] = array($this->table_prefix, 'course_stats', $this->sys_default_lang, $course_id);
		}

		$temp_table = new FeedsTable($this->table_prefix, 'feeds', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'feeds was not converted.';
			$_SESSION['redo_conversion'][$course_title]['FeedsTable'] = array($this->table_prefix, 'feeds', $this->sys_default_lang, $course_id);
		}

		$temp_table = new FileStorageGroupsTable($this->table_prefix, 'file_storage_groups', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'file_storage_groups was not converted.';
			$_SESSION['redo_conversion'][$course_title]['FileStorageGroupsTable'] = array($this->table_prefix, 'file_storage_groups', $this->sys_default_lang, $course_id);
		}

		$temp_table = new ForumsAccessedTable($this->table_prefix, 'forums_accessed', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'forums_accessed was not converted.';
			$_SESSION['redo_conversion'][$course_title]['ForumsAccessedTable'] = array($this->table_prefix, 'forums_accessed', $this->sys_default_lang, $course_id);
		}

		$temp_table = new ForumsCoursesTable($this->table_prefix, 'forums_courses', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'forums_courses was not converted.';
			$_SESSION['redo_conversion'][$course_title]['ForumsCoursesTable'] = array($this->table_prefix, 'forums_courses', $this->sys_default_lang, $course_id);
		}

		$temp_table = new ForumsGroupsTable($this->table_prefix, 'forums_groups', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'forums_groups was not converted.';
			$_SESSION['redo_conversion'][$course_title]['ForumsGroupsTable'] = array($this->table_prefix, 'forums_groups', $this->sys_default_lang, $course_id);
		}

		$temp_table = new ForumsSubscriptionsTable($this->table_prefix, 'forums_subscriptions', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'forums_subscriptions was not converted.';
			$_SESSION['redo_conversion'][$course_title]['ForumsSubscriptionsTable'] = array($this->table_prefix, 'forums_subscriptions', $this->sys_default_lang, $course_id);
		}

		$temp_table = new GroupsMembersTable($this->table_prefix, 'groups_members', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'groups_members was not converted.';
			$_SESSION['redo_conversion'][$course_title]['GroupsMembersTable'] = array($this->table_prefix, 'groups_members', $this->sys_default_lang, $course_id);
		}

		$temp_table = new HandbookNotesTable($this->table_prefix, 'handbook_notes', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'handbook_notes was not converted.';
			$_SESSION['redo_conversion'][$course_title]['HandbookNotesTable'] = array($this->table_prefix, 'handbook_notes', $this->sys_default_lang, $course_id);
		}

		$temp_table = new InstructorApprovalsTable($this->table_prefix, 'instructor_approvals', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'instructor_approvals was not converted.';
			$_SESSION['redo_conversion'][$course_title]['InstructorApprovalsTable'] = array($this->table_prefix, 'instructor_approvals', $this->sys_default_lang, $course_id);
		}

		$temp_table = new LanguagesTable($this->table_prefix, 'languages', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'languages was not converted.';
			$_SESSION['redo_conversion'][$course_title]['LanguagesTable'] = array($this->table_prefix, 'languages', $this->sys_default_lang, $course_id);
		}

		$temp_table = new LanguagePagesTable($this->table_prefix, 'language_pages', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'language_pages was not converted.';
			$_SESSION['redo_conversion'][$course_title]['LanguagePagesTable'] = array($this->table_prefix, 'language_pages', $this->sys_default_lang, $course_id);
		}

		$temp_table = new LanguageTextTable($this->table_prefix, 'language_text', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'language_text was not converted.';
			$_SESSION['redo_conversion'][$course_title]['LanguageTextTable'] = array($this->table_prefix, 'language_text', $this->sys_default_lang, $course_id);
		}

		$temp_table = new MailQueueTable($this->table_prefix, 'mail_queue', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'mail_queue was not converted.';
			$_SESSION['redo_conversion'][$course_title]['MailQueueTable'] = array($this->table_prefix, 'mail_queue', $this->sys_default_lang, $course_id);
		}

		$temp_table = new MasterListTable($this->table_prefix, 'master_list', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'master_list was not converted.';
			$_SESSION['redo_conversion'][$course_title]['MasterListTable'] = array($this->table_prefix, 'master_list', $this->sys_default_lang, $course_id);
		}
	
		$temp_table = new MemberTrackTable($this->table_prefix, 'member_track', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'member_track was not converted.';
			$_SESSION['redo_conversion'][$course_title]['MemberTrackTable'] = array($this->table_prefix, 'member_track', $this->sys_default_lang, $course_id);
		}

		$temp_table = new ModulesTable($this->table_prefix, 'modules', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'modules was not converted.';
			$_SESSION['redo_conversion'][$course_title]['ModulesTable'] = array($this->table_prefix, 'modules', $this->sys_default_lang, $course_id);
		}

		$temp_table = new PollsMembersTable($this->table_prefix, 'polls_members', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'polls_members was not converted.';
			$_SESSION['redo_conversion'][$course_title]['PollsMembersTable'] = array($this->table_prefix, 'polls_members', $this->sys_default_lang, $course_id);
		}

		$temp_table = new RelatedContentTable($this->table_prefix, 'related_content', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'related_content was not converted.';
			$_SESSION['redo_conversion'][$course_title]['RelatedContentTable'] = array($this->table_prefix, 'related_content', $this->sys_default_lang, $course_id);
		}

		$temp_table = new TestsGroupsTable($this->table_prefix, 'tests_groups', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'tests_groups was not converted.';
			$_SESSION['redo_conversion'][$course_title]['TestsGroupsTable'] = array($this->table_prefix, 'tests_groups', $this->sys_default_lang, $course_id);
		}

		$temp_table = new TestsQuestionsAssocTable($this->table_prefix, 'tests_questions_assoc', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'tests_questions_assoc was not converted.';
			$_SESSION['redo_conversion'][$course_title]['TestsQuestionsAssocTable'] = array($this->table_prefix, 'tests_questions_assoc', $this->sys_default_lang, $course_id);
		}

		$temp_table = new TestsResultsTable($this->table_prefix, 'tests_results', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'tests_results was not converted.';
			$_SESSION['redo_conversion'][$course_title]['TestsResultsTable'] = array($this->table_prefix, 'tests_results', $this->sys_default_lang, $course_id);
		}

		$temp_table = new ThemesTable($this->table_prefix, 'themes', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'themes was not converted.';
			$_SESSION['redo_conversion'][$course_title]['ThemesTable'] = array($this->table_prefix, 'themes', $this->sys_default_lang, $course_id);
		}

		$temp_table = new UsersOnlineTable($this->table_prefix, 'users_online', $this->sys_default_lang);
		if (!$temp_table->convert()){
			$errors[]= $this->table_prefix.'users_online was not converted.';
			$_SESSION['redo_conversion'][$course_title]['UsersOnlineTable'] = array($this->table_prefix, 'users_online', $this->sys_default_lang, $course_id);
		}
	}
Beispiel #5
0
 public function checkVersion()
 {
     // only check once per 24 hours per session
     if (isset($this->_session->versionChecked) && $this->_session->versionChecked > time() - 86400) {
         return;
     }
     // only check once in a 24h period for each user
     $lastCheck = ConfigTable::getValue('version_last_check_at.' . $this->getAdmin()->id);
     if ($lastCheck && $lastCheck > time() - 86400) {
         $this->_session->versionChecked = $lastCheck;
         return;
     }
     // is there a new version available?
     if (ViMbAdmin_Version::compareVersion(ViMbAdmin_Version::getLatest()) == 1) {
         $this->addMessage(sprintf(_('Current version is: %s. There is a new version available: %s. See the <a href="https://github.com/opensolutions/ViMbAdmin/blob/master/CHANGELOG">change log</a>.'), ViMbAdmin_Version::VERSION, ViMbAdmin_Version::getLatest()), ViMbAdmin_Message::INFO);
     }
     $this->_session->versionChecked = time();
     ConfigTable::setValue('version_last_check_at.' . $this->getAdmin()->id, $this->_session->versionChecked);
 }