Exemple #1
0
 public function save(Application_Model_Cookie $cookie)
 {
     $data = array('id' => $cookie->getId(), 'nick' => $cookie->getNick(), 'displaymode' => $cookie->getDisplayMode(), 'savename' => $cookie->getSaveName(), 'email' => $cookie->getEmail(), 'password' => $cookie->getPassword(), 'twitter' => $cookie->getTwitter(), 'facebook' => $cookie->getFacebook(), 'ccemail' => $cookie->getCCEmail(), 'created' => date('Y-m-d H:i:s'), 'updated' => date('Y-m-d H:i:s'));
     if (!isset($data['id']) || $data['id'] === 0 || $data['id'] === null || $data['id'] == "") {
         $data['id'] = Application_Model_Cookie::generateRandomKey();
         $cookie->setId($data['id']);
         $this->getDbTable()->insert($data);
     } else {
         unset($data['created']);
         //Added by Pre: Don't want to change Created date when updating.
         $this->getDbTable()->update($data, array('id = ?' => $data['id']));
     }
 }
Exemple #2
0
 public function testCookieModel()
 {
     $cookie = new Application_Model_Cookie();
     $cookie->setNick("testNick");
     $cookie->setEmail("*****@*****.**");
     $cookie->setDisplayMode(1);
     $cookie->setSaveName('testNickSave');
     $cookie->setPassword('testNickPass');
     $cookie->setTwitter('testNickTwit');
     $cookie->setFacebook('testNickFace');
     $cookie->setCCEmail('1');
     if ($cookie->getNick() != "testNick") {
         $this->fail("Nick SetterGetter Failed");
     }
     if ($cookie->getEmail() != "*****@*****.**") {
         $this->fail("Email SetterGetterFailed");
     }
     if ($cookie->getDisplayMode() != 1) {
         $this->fail("DisplayMode SetterGetterFailed");
     }
     if ($cookie->getSaveName() != 'testNickSave') {
         $this->fail("Savename GetterSetterFailed");
     }
     if ($cookie->getPassword() != 'testNickPass') {
         $this->fail("Password SetterGetterFailed");
     }
     if ($cookie->getTwitter() != 'testNickTwit') {
         $this->fail("Twitter SetterGetterFailed");
     }
     if ($cookie->getFacebook() != 'testNickFace') {
         $this->fail("Facebook SetterGetterFailed");
     }
     if ($cookie->getCCEmail() != '1') {
         $this->fail("CCEmail SetterGetterFailed");
     }
     $rkey = $cookie->generateRandomKey();
     if ($rkey == $cookie->generateRandomKey()) {
         $this->fail("Random Keys Aren't Random They're '{$rkey}'");
     }
     if (strlen($rkey) != 60) {
         $this->fail("Random Keys The Wrong Length, '{$rkey}' isn't 60 long");
     }
 }