Example #1
0
 public function testAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     //		Send love to one user
     //		$userMapper = new Application_Model_UserMapper();
     //		$user = $userMapper->find(1040);
     //		$love = new Sendlove_Love();
     //		if ($love->sendLove($this->getSession()->nickname, $user->getNickname(), 'to test something')) {
     //			echo 'Success';
     //		} else {
     //			echo 'Error occured';
     //		}
     //		Send love to all users
     //		$love = new Sendlove_Love();
     //		if ($love->sendLoveToAll($this->getSession()->nickname, 'simply because ...')) {
     //			echo 'Success';
     //		} else {
     //			echo 'Error occured';
     //		}
     //		var_dump(Sendlove_Utilities::createPassword());
     //		Send love to selected users
     //		$love = new Sendlove_Love();
     //		if ($love->sendLoveToSelected('Tom', 'testing again', array(1129, 1226))) {
     //			echo 'Success';
     //		} else {
     //			echo 'Error occured';
     //		}
     //		Get received love from user
     $love = new Sendlove_Love();
     var_dump($love->getLoveReceivedAmount(1129, 15));
     //		Get sent love from user
     $love = new Sendlove_Love();
     var_dump($love->getLoveSentAmount(1129, 15));
     //		Get received messages from user
     $love = new Sendlove_Love();
     var_dump($love->getLoveReceivedMessages(1129, 15));
     //		Get sent messages from user
     $love = new Sendlove_Love();
     var_dump($love->getLoveSentMessages(1129, 15));
 }
Example #2
0
 public function addAction($email = null)
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $validator = new Zend_Validate_EmailAddress();
     if ($validator->isValid($this->getRequest()->getParam('email'))) {
         $splitEmail = explode('@', $this->getRequest()->getParam('email'));
         $password = Sendlove_Utilities::createPassword();
         $token = uniqid();
         $login = Zend_Json::decode($this->_helper->api(array('app' => $this->_helper->api->name('login'), 'key' => $this->_helper->api->key('login'), 'token' => $token, 'admin_id' => $this->getSession()->userid, 'user_data' => array(array('username' => $this->getRequest()->getParam('email'), 'password' => $password, 'nickname' => $splitEmail[0], 'Active' => 1, 'Confirmed' => 1, 'status' => 'new'))), $this->_helper->api->endpoint('login') . 'admincreateusers'));
         if ($login['error'] == 0) {
             if ($login['token'] == $token) {
                 if ($this->getRequest()->getParam('sendlove')) {
                     $love = new Sendlove_Love();
                     $love->sendLove($this->getLoveEmail(), $this->getSession()->username, 'Welcome to SendLove');
                 }
                 $companyMapper = new Admin_Model_CompanyMapper();
                 $company = $companyMapper->find($this->_helper->config('application')->companyid);
                 if (!$this->sendCreateMail(array('creator_nickname' => $this->getSession()->nickname, 'creator_email' => $this->getSession()->username, 'company_name' => $company->getCompany_name(), 'url' => $this->_helper->config('application')->loveLoginUrl, 'user_username' => $this->getRequest()->getParam('email'), 'user_password' => $password))) {
                     throw new Exception('Email could not be sent!');
                 }
                 // Get the user data
                 $user = $login['0'][0];
                 $newUsers[] = array('id' => $user['id'], 'username' => $user['username'], 'nickname' => $user['nickname'], 'active' => 1, 'confirmed' => 1);
                 echo Zend_Json::encode(array('success' => true, 'message' => 'User successfully added', 'users' => $newUsers));
             } else {
                 echo Zend_Json::encode(array('success' => false, 'message' => $login['message']));
             }
         } else {
             echo Zend_Json::encode(array('success' => false, 'message' => 'Could not add the user.'));
         }
     } else {
         echo Zend_Json::encode(array('success' => false, 'message' => 'No valid email address.'));
     }
 }
Example #3
0
 public function getUserLoveCount($request)
 {
     $love = new Sendlove_Love();
     return $love->getUserLoveCount($request);
 }