Пример #1
0
 public function testClear()
 {
     DinklyFlash::set('clear_test_key_1', '1');
     DinklyFlash::set('clear_test_key_hello', 'world');
     $this->assertTrue(DinklyFlash::exists('clear_test_key_1'));
     $this->assertTrue(DinklyFlash::exists('clear_test_key_hello'));
     DinklyFlash::clear();
     $this->assertFalse(DinklyFlash::exists('clear_test_key_1'));
     $this->assertFalse(DinklyFlash::exists('clear_test_key_hello'));
 }
Пример #2
0
 /**
  * Loads default admin login and runs authentication
  * 
  * @return bool: always returns false on successful construction of default admin module
  * 
  */
 public function loadDefault()
 {
     if (isset($_POST['username']) && isset($_POST['password'])) {
         if (!DinklyUser::authenticate($_POST['username'], $_POST['password'])) {
             DinklyFlash::set('invalid_login', 'Invalid login');
         } else {
             $this->loadModule('admin', 'home', 'default', true);
         }
     }
     return true;
 }
Пример #3
0
 public function loadEdit($parameters)
 {
     $this->group = new DinklyGroup();
     if (isset($parameters['id'])) {
         $this->group->init($parameters['id']);
         if (isset($_POST['name'])) {
             $this->validateGroupPost($_POST);
             //If we have no errors, save the group and redirect to detail
             if ($this->errors == array()) {
                 $this->group->save();
                 DinklyFlash::set('good_group_message', 'Group successfully updated');
                 return $this->loadModule('admin', 'group', 'detail', true, true, array('id' => $this->group->getId()));
             }
         }
         return true;
     }
     return false;
 }
 /**
  * Load default view
  *
  * @return bool: always returns true on successful construction of view
  *
  */
 public function loadDefault()
 {
     $this->user = $this->logged_user;
     //Handle save
     if (isset($_POST['user-id'])) {
         $this->user->init($_POST['user-id']);
         //Make sure the submitted user matches the one logged in
         if ($_POST['user-id'] == DinklyUser::getLoggedId()) {
             $this->validateUserPost($_POST);
             if ($_POST['date-format'] == 'MM/DD/YY') {
                 $this->user->setDateFormat('m/d/y');
             } else {
                 if ($_POST['date-format'] == 'DD/MM/YY') {
                     $this->user->setDateFormat('d/m/y');
                 }
             }
             if ($_POST['time-format'] == '12') {
                 $this->user->setTimeFormat('g:i a');
             } else {
                 if ($_POST['time-format'] == '24') {
                     $this->user->setTimeFormat('H:i');
                 }
             }
             //If we have no errors, save the user
             if ($this->errors == array()) {
                 $this->user->save();
                 $this->logged_user = $this->user;
                 DinklyFlash::set('good_user_message', 'Profile Updated');
             }
         }
     }
     //Timezone dropdown (http://stackoverflow.com/a/7022536/53079)
     $utc = new DateTimeZone('UTC');
     $dt = new DateTime('now', $utc);
     $this->select_options = null;
     $timezone_identifiers = DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, 'US');
     foreach ($timezone_identifiers as $tz) {
         $current_tz = new DateTimeZone($tz);
         $offset = $current_tz->getOffset($dt);
         $transition = $current_tz->getTransitions($dt->getTimestamp(), $dt->getTimestamp());
         $abbr = $transition[0]['abbr'];
         $selected = null;
         if ($this->user->getTimeZone() == $tz) {
             $selected = 'selected="selected"';
         }
         $this->select_options .= '<option ' . $selected . ' value="' . $tz . '">' . str_replace('_', ' ', $tz) . ' [' . $abbr . ' ' . DinklyUser::formatOffset($offset) . ']</option>';
     }
     return true;
 }