Beispiel #1
0
 /**
  * This method prevents setting some
  * values directly
  *
  * (non-PHPdoc)
  *
  * @see ArrayObject::offsetSet()
  *
  * @param mixed $index
  * @param mixed $newval
  *
  * @throws DevException
  */
 public function offsetSet($index, $newval)
 {
     switch ($index) {
         case 'accepted':
             throw new DevException('value of accepted cannot be set directly. Use setAccepted() or unsetAccepted() methods');
             break;
         case 'i_comments':
             throw new DevException('value of i_comments cannot be set directly. Use increaseCommentsCount() method');
             break;
         case 'comments':
         case 'a_comments':
             throw new DevException('value of a_comments cannot be set directly. Must use setComments() method for that');
             break;
         case 'i_down':
         case 'i_up':
         case 'i_votes':
             throw new DevException('value of ' . $index . ' keys cannot be set directly. Use addDownVote or addUpVote to add votes');
             break;
         case 'a_deleted':
         case 'i_del_ts':
             throw new DevException('value of ' . $index . ' cannot be set directly. Must use setDeleted() method for that');
             break;
         case 'a_edited':
             throw new DevException('value of a_edited cannot be set directly. Must use setEdited() method for that');
             break;
         default:
             parent::offsetSet($index, $newval);
     }
 }
Beispiel #2
0
 /**
  * Create new record in EMAILS table for this new user
  * but only if user has provided email address
  *
  * @return object $this
  */
 protected function saveEmailAddress()
 {
     if (!empty($this->aFbUserData['email'])) {
         $coll = $this->Registry->Mongo->EMAILS;
         $coll->ensureIndex(array('email' => 1), array('unique' => true));
         $a = array('email' => \mb_strtolower($this->aFbUserData['email']), 'i_uid' => $this->User->getUid(), 'has_gravatar' => \Lampcms\Gravatar::factory($this->aFbUserData['email'])->hasGravatar(), 'ehash' => hash('md5', $this->aFbUserData['email']));
         try {
             $o = \Lampcms\Mongo\Doc::factory($this->Registry, 'EMAILS', $a)->insert();
         } catch (\Exception $e) {
             e('Unable to save email address from Facebook to our EMAILS: ' . $e->getMessage() . ' in ' . $e->getFile() . ' on ' . $e->getLine());
         }
     }
     return $this;
 }
 /**
  * Created a new record in EMAILS collection
  *
  * @return object $this
  */
 protected function createEmailRecord()
 {
     $coll = $this->Registry->Mongo->EMAILS;
     $coll->ensureIndex(array('email' => 1), array('unique' => true));
     $a = array('email' => $this->email, 'i_uid' => $this->Registry->Viewer->getUid(), 'has_gravatar' => \Lampcms\Gravatar::factory($this->email)->hasGravatar(), 'ehash' => hash('md5', $this->email), 'i_code_ts' => time(), 'code' => \substr(hash('md5', \uniqid(\mt_rand())), 0, 12));
     $this->oEmail = \Lampcms\Mongo\Doc::factory($this->Registry, 'EMAILS', $a);
     $res = $this->oEmail->save();
     d('$res: ' . $res);
     return $this;
 }
Beispiel #4
0
 public function __construct(Registry $Registry)
 {
     parent::__construct($Registry, 'RESOURCE');
 }
 /**
  * This method prevents setting some
  * values directly
  *
  * (non-PHPdoc)
  * @see ArrayObject::offsetSet()
  */
 public function offsetSet($index, $newval)
 {
     switch ($index) {
         case 'i_comments':
             throw new DevException('value of i_comments cannot be set directly. Use increaseCommentsCount() method');
             break;
         case 'i_down':
         case 'i_up':
         case 'i_votes':
             throw new DevException('value of ' . $index . ' keys cannot be set directly. Use addDownVote or addUpVote to add votes');
             break;
         case 'a_deleted':
         case 'i_del_ts':
             throw new DevException('value of ' . $index . ' cannot be set directly. Must use setDeleted() method for that');
             break;
         case 'i_ans':
             throw new DevException('value of i_ans cannot be set directly. Use updateAnswerCount() method');
             break;
         case 'i_views':
             throw new DevException('value of i_ans cannot be set directly. Use increaseViews() method');
             break;
         case 'a_edited':
             throw new DevException('value of a_edited cannot be set directly. Must use setEdited() method for that');
             break;
         case 'a_closed':
             throw new DevException('value of a_closed cannot be set directly. Must use setClosed() method for that');
             break;
         case 'comments':
         case 'a_comments':
             throw new DevException('value of a_comments cannot be set directly. Must use setComments() method for that');
             break;
             /*case 'a_latest':
             	 throw new DevException('value of a_latest cannot be set directly. Must use setLatestAnswer() method for that');
             	 break;*/
         /*case 'a_latest':
         	 throw new DevException('value of a_latest cannot be set directly. Must use setLatestAnswer() method for that');
         	 break;*/
         case 'i_sel_uid':
         case 'i_sel_ans':
             throw new DevException('value of ' . $index . ' cannot be set directly. Must use setBestAnswer() method for that');
             break;
         default:
             parent::offsetSet($index, $newval);
     }
 }
Beispiel #6
0
 /**
  * Some keys should not be set directly
  * but instead use proper setter methods
  *
  * @todo must go over all classes and see
  *       which classes set values directly using
  * ->offsetSet or as assignment
  *       and add some of the more important
  *       keys here. For example: language, locale,
  * ,username(maybe), pwd(maybe), email,
  *       timezone should go through validation
  *
  * (non-PHPdoc)
  * @see  ArrayObject::offsetSet()
  *
  * @param mixed $index
  * @param mixed $newval
  *
  * @throws DevException
  */
 public function offsetSet($index, $newval)
 {
     switch ($index) {
         case Schema::ROLE:
             throw new DevException('User Role cannot be set directly, must be set using setRoleId() method');
             //$this->setRoleId($newval);
             break;
         case Schema::REPUTATION:
             throw new DevException('value of i_rep cannot be set directly. Use setReputation() method');
             break;
         case Schema::TIMEZONE:
         case 'timezone':
             //$this->setTimezone($newval);
             throw new DevException('Value of timezone should be set using setTimezone() method');
             break;
         default:
             parent::offsetSet($index, $newval);
     }
 }
 /**
  * Some keys should not be set directly
  * but instead use proper setter methods
  *
  * @todo must go over all classes and see
  * which classes set values directly using
  * ->offsetSet or as assignment
  * and add some of the more important
  * keys here. For example: language, locale,
  * ,username(maybe), pwd(maybe), email,
  * timezone should go through validation
  *
  * (non-PHPdoc)
  * @see ArrayObject::offsetSet()
  */
 public function offsetSet($index, $newval)
 {
     switch ($index) {
         case 'role':
             throw new DevException('User Role cannot be set directly, must be set using setRoleId() method');
             //$this->setRoleId($newval);
             break;
         case 'i_pp':
             throw new DevException('value of i_pp cannot be set directly. Use setProfitPoint() method');
             break;
         case 'tz':
         case 'timezone':
             //$this->setTimezone($newval);
             throw new DevException('Value of timezone should be set using setTimezone() method');
             break;
         default:
             parent::offsetSet($index, $newval);
     }
 }
 public function setUp()
 {
     $this->Registry = new Registry();
     $this->oMongoDoc = \Lampcms\Mongo\Doc::factory($this->Registry, $this->COLLNAME);
 }
 /**
  *
  * Create object representing email address
  * of current Viewer
  *
  * @throws \Lampcms\NoemailException if unable to find email address
  * of current Viewer
  *
  * @return object $this
  */
 protected function getEmailObject()
 {
     $this->email = strtolower($this->Registry->Viewer->email);
     if (empty($this->email)) {
         /**
          * @todo
          * Translate String
          */
         throw new \Lampcms\NoemailException($this->_('You have not selected any email address for your account yet'));
     }
     try {
         $this->oEmail = \Lampcms\Mongo\Doc::factory($this->Registry, 'EMAILS')->byEmail($this->email);
         if ('' == $this->oEmail['email']) {
             /**
              * @todo
              * Translate String
              */
             throw new \Lampcms\NoemailException($this->_('You have not selected any email address for your account yet'));
         }
     } catch (\MongoException $e) {
         /**
          * @todo
          * Translate String
          */
         throw new \Lampcms\NoemailException($this->_('You have not selected any email address for your account yet'));
     }
     return $this;
 }
Beispiel #10
0
 public function __construct(\Lampcms\Registry $Registry)
 {
     parent::__construct($Registry, 'API_CLIENTS');
 }