Ejemplo n.º 1
0
 public function init()
 {
     //get model and service
     $this->_model = RFLib_Core::getModel('User');
     $this->_authService = RFLib_Core::getService('Authentication');
     unset($this->view->errorMsg);
 }
Ejemplo n.º 2
0
 /**
  * Get user info from the auth session
  *
  * @param string|null $info
  * @return null|Zend_View_Helper_AuthInfo
  */
 public function authInfo($info = null)
 {
     if (null === $this->_authService) {
         $this->_authService = RFLib_Core::getService('authentication');
     }
     if (null === $info) {
         return $this;
     }
     if (false === $this->isLogined()) {
         return null;
     }
     return $this->_authService->getIdentity()->{$info};
 }
Ejemplo n.º 3
0
 /**
  * Create user post data
  *
  * @param array $data
  * @param string $type 'Q'=Question 'A'=Answer or Reply
  * @return boolean
  */
 public function posted($data, $type = 'Q')
 {
     $auth = RFLib_Core::getService('authentication')->getAuth();
     if (!$auth->hasIdentity()) {
         return false;
     }
     $user = $auth->getStorage()->read();
     if (!isset($data['post_id']) | !isset($data['post_category_id'])) {
         return false;
     }
     $date = new Zend_Date();
     $default = array('user_id' => $user['id'], 'post_type' => $type, 'post_at' => $date->getTimestamp());
     $data = array_merge($data, $default);
     return $this->getTable('Userpost')->saveRow($data, null);
 }
Ejemplo n.º 4
0
 private function _save($form, $data, $defaults = array())
 {
     if (!isset($data['user_id'])) {
         $auth = RFLib_Core::getService('authentication')->getAuth();
         if (!$auth->hasIdentity()) {
             return false;
         }
         $user = $auth->getStorage()->read();
         $data['user_id'] = $user['id'];
     }
     if (!$form->isValid($data)) {
         return false;
     }
     $defaults['ip_address'] = ip2long(Zend_Controller_Front::getInstance()->getRequest()->getClientIp());
     // apply any defaults
     foreach ($defaults as $col => $value) {
         $data[$col] = $value;
     }
     $date = new Zend_Date();
     $data['updated_at'] = $date->getTimestamp();
     $row = array_key_exists('id', $data) ? $this->findById($data['id']) : null;
     if (null === $row) {
         $date = new Zend_Date();
         $data['created_at'] = $date->getTimestamp();
     }
     return $this->getTable('Answer')->saveRow($data, $row);
 }
Ejemplo n.º 5
0
 /**
  * Save question data
  * @param array|Wenda_Model_DbTable_QuestionTable $data
  * @return boolean
  */
 protected function _save($data)
 {
     $auth = RFLib_Core::getService('authentication')->getAuth();
     if (!$auth->hasIdentity()) {
         return false;
     }
     $user = $auth->getStorage()->read();
     $date = new Zend_Date();
     if (isset($data['id'])) {
         $row = $this->getTable('Question')->findById($data['id']);
     } else {
         $row = null;
     }
     if (null === $row) {
         $data['user_id'] = $user['id'];
         $data['created_at'] = $date->getTimestamp();
         $data['expired_at'] = $date->addWeek(1)->getTimestamp();
         $data['ip_address'] = ip2long(Zend_Controller_Front::getInstance()->getRequest()->getClientIp());
     } else {
         $data['updated_at'] = $date->getTimestamp();
     }
     $date = null;
     return $this->getTable('Question')->saveRow($data, $row);
 }