Example #1
0
 public static function login($email, $password)
 {
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($db);
     $authAdapter->setTableName('users');
     $authAdapter->setIdentityColumn('email');
     $authAdapter->setCredentialColumn('password');
     $authAdapter->setCredentialTreatment('?');
     $authAdapter->setIdentity($email);
     $authAdapter->setCredential($password);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     if ($result->isValid()) {
         $data = $authAdapter->getResultRowObject(null, 'password');
         $oUser = null;
         $tUserInfo = new Table_UsersInfo();
         $data = $tUserInfo->getUser($data->userID);
         $oUser->school_id = $data->school_id;
         $oUser->user_id = $data->user_id;
         $oUser->email = $email;
         if (is_null($oUser)) {
             return false;
         }
         $auth->getStorage()->write($oUser);
         return true;
     }
     return false;
 }
Example #2
0
 public function indexAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $userinfo['first_name'] = $this->getRequest()->getParam('first_name');
     $userinfo['last_name'] = $this->getRequest()->getParam('last_name');
     $userinfo['school_id'] = $this->getRequest()->getParam('school_id');
     $userinfo['school_year'] = $this->getRequest()->getParam('school_year');
     $userinfo['class_year'] = $this->getRequest()->getParam('class_year');
     $userinfo['status'] = 1;
     $userCredentails['email'] = $this->getRequest()->getParam('email');
     $userCredentails['password'] = $this->getRequest()->getParam('password');
     $tUsersInfo = new Table_UsersInfo();
     if ($userid = $tUsersInfo->createUser($userinfo)) {
         $userCredentails['userID'] = $userid;
         $tUsers = new Table_Users();
         $tUsers->createUserCredentials($userCredentails);
         $tActivity = new Table_Activities();
         $tActivity->createActivity($userid, 1, $userinfo['school_id'], $userinfo['school_id']);
         User::login($userCredentails['email'], $userCredentails['password']);
         $this->_redirect(HTTP_HOST . "/chatroom/chat");
     }
 }
Example #3
0
 public function schoolTreeMenu($states, $user)
 {
     $output = "";
     $School = new Table_Schools();
     $Pop = new Table_Popularity();
     $tUser = new Table_UsersInfo();
     $class_year = $tUser->getUser($user->user_id)->class_year;
     //print_r($class_year);die;
     foreach ($states as $key => $state) {
         if ($schoollist = $School->getSchoolByState($key)) {
             $count = count($schoollist);
             $output .= "<li class='expandable'><div class='hitarea expandable-hitarea'></div>" . $state;
             $output .= "<ul  class='ulhide' style='display:none;'>";
             foreach ($schoollist as $num => $s) {
                 $popnum = $Pop->getPopularity(1, $s["school_id"], $class_year, $user->school_id);
                 if (strlen($s["name"]) > 30) {
                     $name = substr($s["name"], 0, 30) . "...";
                 } else {
                     $name = $s["name"];
                 }
                 $output .= "<li";
                 if ($count == $num + 1) {
                     $output .= " class='last' ";
                 }
                 $output .= ">\n   \t\t\t\t\t\t\t<span class='popularity'   name='" . $s["school_id"] . "'>" . $name . "(" . $popnum . ")</span>\n   \t\t  \n   \t\t\t\t\t\t\t</li>";
             }
             $output .= "\t</ul></li>";
         } else {
             $output .= "<li>" . $state . "</li>";
         }
     }
     $this->view->output = $output;
     $this->view->setScriptPath(APPLICATION_PATH . '/layouts/helpers/school-menu/');
     $sHTML = $this->view->render('school-tree-menu.phtml');
     return $sHTML;
 }
Example #4
0
 public function addcommentAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $arResult = array('error' => '');
     if ($comment = $this->getRequest()->getParam('comments', '')) {
         if ($comment == '') {
             return false;
         } else {
             $tComment = new Table_Comments();
             $comment_id = $tComment->createComment($this->user->school_id, $comment);
             if ($comment_id > 0) {
                 $tActivity = new Table_Activities();
                 $tActivity->createActivity($this->user->user_id, 29, $this->user->school_id, $this->user->school_id, $comment_id);
             }
         }
         $tUser = new Table_UsersInfo();
         $creatorid = $this->user->user_id;
         $creator = '<a href="../profile/profile?uid=' . $creatorid . '" >' . $tUser->getUserName($creatorid) . '</a>';
         $arResult['creator'] = $creator;
     } else {
         $arResult['error'] = "Please enter comment";
     }
     $this->_helper->json($arResult, true, false);
 }
Example #5
0
 public function editAction()
 {
     $form = new Forms_Profile();
     $form->submit->setLabel('Save');
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $firstname = $form->getValue('first_name');
             $lastname = $form->getValue('last_name');
             $schoolyear = $form->getValue('school_year');
             $classyear = $form->getValue('class_year');
             $phonenumber = $form->getValue('phone_num');
             $facebook = $form->getValue('facebook');
             $linkedin = $form->getValue('linkedin');
             $twitter = $form->getValue('twitter');
             $location = $form->getValue('location');
             $status = $form->getValue('status');
             $altemail = $form->getValue('altemail');
             $summary = $form->getValue('summary');
             $interests = $form->getValue('interests');
             $favstuspot = $form->getValue('favstuspot');
             $favdrink = $form->getValue('favdrink');
             $pet = $form->getValue('pet');
             $petpeeve = $form->getValue('petpeeve');
             $data = array('first_name' => $firstname, 'last_name' => $lastname, 'school_year' => $schoolyear, 'class_year' => $classyear, 'phone_num' => $phonenumber, 'facebook' => $facebook, 'linkedin' => $linkedin, 'twitter' => $twitter, 'location' => $location, 'status' => $status, 'altemail' => $altemail, 'summary' => $summary, 'interests' => $interests, 'favstuspot' => $favstuspot, 'favdrink' => $favdrink, 'pet' => $pet, 'petpeeve' => $petpeeve);
             $tUser = new Table_UsersInfo();
             $tUser->update($data, 'user_id=' . $this->user->user_id);
             /*
             public function updateAlbum($id, $artist, $title)
             						{
             			$data = array(
             			'artist' => $artist,
             			'title' => $title,
             			);
             				$this->update($data, 'id = '. (int)$id);
             					}
             */
             $this->_helper->redirector('index');
         } else {
             $form->populate($formData);
         }
     } else {
         $tUser = new Table_UsersInfo();
         $temp = $tUser->getUser($this->user->user_id);
         $row = $temp->toArray();
         $form->populate($row);
     }
 }