public function sendRequestNotification($requestId) { $request = new Application_Model_Request(); $request = $request->find($requestId); if (false === $request) { return false; } $departmentId = $request->getDepartmentId(); $dept = new Application_Model_Department(); $dept = $dept->find($departmentId); if ($dept === false) { return false; } $user = new Application_Model_User(); $users = $user->fetchAll("department_id='{$departmentId}' and status='active' and id ='{$dept->getDepartmentHeadId()}'"); if (count($users) == 0) { return false; } $emails = array(); foreach ($users as $_user) { $emails[$_user->getFirstName() . " " . $_user->getLastName()] = $_user->getEmail(); } if (count($emails) == 0) { return false; } $user = new Application_Model_User(); $requestedBy = $user->find($request->getRequestedBy()); $from_email = $this->settingValue('admin_email'); $from_name = $this->settingLable('admin_email'); /*---Template-----*/ $template = $this->getEmailTemplate('request_notification_email'); $htmlBody = $template['body']; $htmlBody = str_replace("__REQUESTER_NAME__", $requestedBy->getFirstName() . " " . $requestedBy->getLastName(), $htmlBody); $htmlBody = str_replace("__REQUESTER_EMAIL__", $requestedBy->getEmail(), $htmlBody); $htmlBody = str_replace("__REQUESTER_EMP_CODE__", $requestedBy->getEmployeeCode(), $htmlBody); $htmlBody = str_replace("__REQUEST__", $request->getRequest(), $htmlBody); /*---------------------*/ $subject = $template['subject']; $this->setBodyHtml($htmlBody); $this->setFrom($from_email, $from_name); $this->addTo($emails); $this->setSubject($subject); $this->send(); }
public function albumPhotoCommentAction() { $this->_helper->layout()->disableLayout(); $objModelComment = new Application_Model_Comment(); $objModelUser = new Application_Model_User(); $arrPostVal = $this->getRequest()->getParams(); $usersNs = new Zend_Session_Namespace("members"); $userFullName = $usersNs->userFullName; $item_id = $arrPostVal['item_id']; $comment = $arrPostVal['comment']; $item_type = $arrPostVal['item_type']; $userId = $usersNs->userId; $option['comment'] = addslashes(strip_tags($comment)); $option['parentId'] = 0; $option['itemType'] = $item_type; $option['itemId'] = $item_id; $option['addedon'] = time(); $option['updatedon'] = time(); $option['userId'] = $userId; $option['publish'] = 1; $objModelComment->setOptions($option); $commentId = $objModelComment->save(); /*-------------------------------------------------*/ $valUser = $objModelUser->find($userId); $this->view->userImage = $valUser->getImage(); $this->view->userFullName = $userFullName; $this->view->comment = nl2br(strip_tags($comment)); $this->view->commentId = $commentId; }
public function employeeInfoAction() { $this->view->layout()->disableLayout(); $userId = $this->_getParam("id"); $model = new Application_Model_User(); $user = $model->find($userId); if (false === $user) { exit("Operation failed!"); } $this->view->user = $user; }
public function getAllAlbumComment($albumId, $item_type) { $objModelComment = new Application_Model_Comment(); $objModelAlbum = new Album_Model_Album(); $objModelAlbumPhoto = new Album_Model_AlbumPhoto(); $objModelUser = new Application_Model_User(); /*------------------- LoggedIn User -----------------*/ $userNs = new Zend_Session_Namespace("members"); $loggedInUserId = $userNs->userId; /*-------------- GET Item Posted User ---------------*/ if ($item_type == 'photo_comment') { $valItem = $objModelAlbumPhoto->find($albumId); } else { if ($item_type == 'album_comment') { $valItem = $objModelAlbum->find($albumId); } } $itemCreatedUserId = $valItem->userId; /*---------------------------------------------------*/ $arrAllComment = array(); $whereComment = "parent_id='0' AND item_type='{$item_type}' AND item_id='{$albumId}' AND publish='1'"; $orderComment = "addedon ASC"; $arrComment = $objModelComment->fetchAll($whereComment, $orderComment); $i = 0; foreach ($arrComment as $com) { $userId = $com->userId; $permission = $this->checkCommentRemovePermission($loggedInUserId, $itemCreatedUserId, $userId); $valUser = $objModelUser->find($userId); $arrAllComment[$i]['commenterName'] = $valUser->getFirstName() . ' ' . $valUser->getLastName(); $arrAllComment[$i]['commenterUserName'] = $valUser->getUsername(); $arrAllComment[$i]['commenterUserId'] = $valUser->getId(); $arrAllComment[$i]['imageName'] = $valUser->getImage(); $arrAllComment[$i]['comment'] = nl2br(stripslashes($com->comment)); $arrAllComment[$i]['commentId'] = stripslashes($com->id); $arrAllComment[$i]['addedon'] = $com->addedon; $arrAllComment[$i]['permission'] = $permission; $i++; } return $arrAllComment; }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 27-Jan-2011 * @Description : Report Journal/Wall and other items as abuse to admin */ public function reportAbuseAction() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); //get request parameters $item_id = $this->_getParam('item_id'); $item_type = $this->_getParam('item_type'); //get logged in user ID $usersNs = new Zend_Session_Namespace('members'); $user_id = $usersNs->userId; if ($user_id == "" || $user_id == 0) { $JsonResultArray = array('error' => 1, 'response' => "Please login to report abuse."); echo Zend_Json::encode($JsonResultArray); exit; } if ($item_id == "" || $item_id == 0) { $JsonResultArray = array('error' => 2, 'response' => "No item is selected to report abuse."); echo Zend_Json::encode($JsonResultArray); exit; } if ($item_type == "") { $JsonResultArray = array('error' => 2, 'response' => "No item type is selected to report abuse."); echo Zend_Json::encode($JsonResultArray); exit; } //Get user report abuse info for item $modelM = new Application_Model_ReportAbuse(); $modelRes = $modelM->fetchRow("item_id={$item_id} AND item_type='{$item_type}' AND user_id={$user_id}"); if ($modelRes && $modelRes->getStatus() == 1) { $JsonResultArray = array('error' => 2, 'response' => "You've already reported this as abuse."); echo Zend_Json::encode($JsonResultArray); exit; } else { $params["itemId"] = $item_id; $params["itemType"] = $item_type; $params["userId"] = $user_id; $params["comment"] = ""; $params["status"] = 1; $modelM->setOptions($params); $dbRes = $modelM->save(); if ($dbRes) { //get item type information $itemTitle = ""; $authorId = ""; $author = ""; if ($item_type == 'blog') { $blogM = new Application_Model_Blog(); $blogRes = $blogM->find($item_id); $itemTitle = $blogRes->getTitle(); $authorId = $blogRes->getUserId(); $blog_url = Zend_Registry::get('siteurl') . "/journal/view-post/blog_id/" . $item_id; $itemTitle = "<a href='" . $blog_url . "' target='_blank'>" . $itemTitle . "</a>"; } else { if ($item_type == 'wall') { $wallM = new Application_Model_Wall(); $wallRes = $wallM->find($item_id); $itemTitle = $wallRes->getStatus(); $authorId = $wallRes->getUserId(); } else { if ($item_type == 'photo') { $objModelAlbumPhoto = new Album_Model_AlbumPhoto(); $albumPhotoRes = $objModelAlbumPhoto->find($item_id); $itemTitle = $albumPhotoRes->getName(); $authorId = $albumPhotoRes->getUserId(); } } } //get Blog/Wall owner/author user information if ($authorId != "") { $useAuthor = new Application_Model_User(); $authorRes = $useAuthor->find($authorId); $author = ucfirst($authorRes->getFirstName()) . " " . ucfirst($authorRes->getLastName()) . " (" . $authorRes->getUsername() . ")"; } //get user information who is reporting abuse item $userM = new Application_Model_User(); $userR = $userM->find($user_id); $reporterName = ucfirst($userR->getFirstName()) . " " . ucfirst($userR->getLastName()) . " (" . $userR->getUsername() . ")"; $reporterEmail = $userR->getEmail(); //Now send report abuse email to Administrator $settings = new Admin_Model_GlobalSettings(); $admin_email = $settings->settingValue('report_abuse'); //$admin_email = "*****@*****.**"; $mailOptions['receiver_email'] = $admin_email; $mailOptions['item_type'] = ucfirst($item_type); $mailOptions['item_title'] = $itemTitle; $mailOptions['item_author'] = $author; $mailOptions['reporter_name'] = $reporterName; $mailOptions['reporter_email'] = $reporterEmail; //create mail class object and send the email $Mail = new Base_Mail(); $Mail->sendReportAbuseEmail($mailOptions); //send response $JsonResultArray = array('error' => 3, 'response' => "Consider it reported!"); } else { $JsonResultArray = array('error' => 2, 'response' => "Error occured, please try again later."); } } echo Zend_Json::encode($JsonResultArray); exit; }
public function articleDetailAction() { //$this->_helper->viewRenderer->setNoRender(true); $blockM = new Base_View_Block(); $path = "/layouts/scripts/page/blocks/work-study-volunteer"; $blockM->removeBlock("work-study-volunteer-categories", 'work-study-volunteer'); $params = $this->getRequest()->getParams(); $article_id = $params['id']; $preview = false; $preview = $this->_getParam("preview"); $categoryM = new Application_Model_Category(); $articleM = new Application_Model_Articles(); $data = $articleM->find($article_id); if (false != $data) { $this->view->article = $data; $this->view->preview = $preview; $this->view->categoryId = $categoryId = $data->getCategoryId(); $this->view->categoryM = $categoryM->find($categoryId); $allarticles = $articleM->fetchAll("category_id = {$categoryId} and id != {$article_id}"); /** * @Added By: Mahipal Adhikari * @Added On: 29-Dec-2010 * @Description: get Article user information to display as Author */ $userM = new Application_Model_User(); $userRes = $userM->find($data->getUserId()); $Author = "Admin"; if (false !== $userRes) { $Author = $userRes->getFirstName() . " " . $userRes->getLastName(); $this->view->author = $Author; $this->view->author_username = $userRes->getUsername(); } if (count($allarticles) > 0) { $this->view->allarticles = $allarticles; $blocks = array("name" => "work-study-volunteer-articles", "order" => "8", "path" => $path); $blockM->addBlock($blocks, 'work-study-volunteer'); } } }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 2-Nov-2010 * @Description: Sumbit comment by blog owner */ public function addCommentAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $userNs = new Zend_Session_Namespace('members'); $this->view->userId = $userNs->userId; if (is_null($userNs->userId) && !numeric($userNs->userId)) { $response = "<span style='color:#ff0000;'>Please login to submit your comment on this blog.</span>"; $JsonResultArray = array('error' => 1, 'response' => $response); echo Zend_Json::encode($JsonResultArray); exit; } if ($this->_getParam('comment') == "" || $this->_getParam('comment') == "Comment...") { $response = "<span style='color:#ff0000;'>Please enter your comment.</span>"; $JsonResultArray = array('error' => 1, 'response' => $response); echo Zend_Json::encode($JsonResultArray); exit; } //save comment $commentM = new Application_Model_Comment(); $commentM->setComment($this->_getParam('comment')); $commentM->setItemId($this->_getParam('item_id')); $commentM->setItemType($this->_getParam('item_type')); $commentM->setParentId(0); $commentM->setPublish(1); $commentM->setUserId($userNs->userId); $id = $commentM->save(); //set and display response if ($id > 0) { //get total number of comments $total_comments = $commentM->numComments('blog', $this->_getParam('item_id')); $total_comments = $total_comments . " Comments"; //get comment information to display in comment listings $comment = $commentM->find($id); //$this->view->comment = $objComment; $date = new Base_Date(); $objModelUser = new Application_Model_User(); $objUser = $objModelUser->find($comment->userId); $username = $objUser->getUsername(); $firstname = $objUser->getFirstName(); $lastname = $objUser->getLastName(); $image = $objUser->getThumbnail(); $response = "<div class='my-journal-view-comment-row' id='comment-detail-" . $id . "'>"; $response .= "<div class='my-journal-view-comment-row-l'>"; $response .= "<a href='/" . $username . "'><img width='37px' height='43px' border='0' src='" . $image . "' alt='' /></a>"; $response .= "</div>"; $response .= "<div class='my-journal-view-comment-row-r'>"; $response .= "<p><span><a href='/" . $username . "'>" . $firstname . " " . $lastname . "</a></span> " . $comment->comment . "</p>"; $response .= "<div class='jposted'>Posted " . $date->timeAgo($comment->getAddedon()) . " | "; $response .= "<a href='#add_comment_form' title='Add Comment'>Comment</a> | "; $like_link = "<a href='javascript://' title='Like Comment' onclick='likeComment(" . $id . ", 1)'>Like</a>"; $response .= "<label id='like-comment-label-" . $id . "'>" . $like_link . "</label> | "; $response .= "<a href='javascript://' title='Remove Comment' onclick='removeComment(" . $id . "," . $this->_getParam('item_id') . ")'>Remove</a>"; $response .= "</div></div></div>"; $JsonResultArray = array('error' => 0, 'total_comments' => $total_comments, 'response' => $response); } else { $response = "<span style='color:#ff0000;'>Error occured, Please try again later.</span>"; $JsonResultArray = array('error' => 1, 'response' => $response); } echo Zend_Json::encode($JsonResultArray); exit; }
public function setDefaultJournal($user_id) { $userM = new Application_Model_User(); $user = $userM->find($user_id); if (false !== $user) { $journalM = new Application_Model_Journal(); $journalM->setTitle($user->getFirstName() . "'s Journal"); $journalM->setPublish("published"); $journalM->setStatus("public"); $journalM->setUserId($user_id); $journalM->save(); return true; } return false; }
public function getPhotoInfo($photoId, $userId = NULL, $albumId = NULL) { $objModelAlbumPhoto = new Album_Model_AlbumPhoto(); $objModelVote = new Application_Model_Vote(); /*------------------------- CHECK RELATION ------------------------------*/ $userNs = new Zend_Session_Namespace('members'); $this->view->loggedInUserId = $loggedInUserId = $userNs->userId; $relationCondition = $this->checkRelation($userId, $loggedInUserId); $this->view->relationCondition = $relationCondition; /*-----------------------------------------------------------------------*/ $wherePhoto = "id='{$photoId}' AND ({$relationCondition})"; $arrPhotoIds = array(); $valAlbumPhoto = $objModelAlbumPhoto->fetchAll($wherePhoto); if (!empty($valAlbumPhoto)) { $this->view->photo = $valAlbumPhoto[0]->image; $this->view->name = $valAlbumPhoto[0]->name; $this->view->caption = stripslashes($valAlbumPhoto[0]->caption); $this->view->location = $valAlbumPhoto[0]->location; $this->view->permission = $valAlbumPhoto[0]->permission; $albumId = $valAlbumPhoto[0]->albumId; $this->view->myLatitude = $latitude = $valAlbumPhoto[0]->latitude; $this->view->myLongitude = $longitude = $valAlbumPhoto[0]->longitude; } else { $this->view->imageNotExist = 1; } $this->getAlbumInfo($albumId); // Get album info $this->view->albumId = $albumId; $this->view->photoId = $photoId; $objModelUser = new Application_Model_User(); $valUser = $objModelUser->find($userId); $frienUserName = $valUser->getUsername(); $this->view->likeSrcUrl = Zend_Registry::get('siteurl') . "%2Fprofile%2Fphoto%2Fusername%2F" . $frienUserName . "%2Falbum%2F" . $albumId . "%2Fid%2F" . $photoId; $whereAlbumPhoto = "album_id='{$albumId}' AND status='1' AND ({$relationCondition})"; $orderAlbumPhoto = "addedon DESC"; $arrAlbumPhoto = $objModelAlbumPhoto->fetchAll($whereAlbumPhoto, $orderAlbumPhoto); foreach ($arrAlbumPhoto as $photo) { $arrPhotoIds[] = $photo->id; } $position = array_search($photoId, $arrPhotoIds); $nextPosition = $position + 1; $prevPosition = $position - 1; $arrSize = count($arrPhotoIds); $this->view->photoPosition = $nextPosition; $this->view->numPhotoAlbum = $arrSize; if (array_key_exists($nextPosition, $arrPhotoIds)) { $this->view->nextId = $arrPhotoIds[$nextPosition]; } else { if (isset($arrPhotoIds[0])) { $this->view->nextId = $arrPhotoIds[0]; } } if (array_key_exists($prevPosition, $arrPhotoIds)) { $this->view->prevId = $arrPhotoIds[$prevPosition]; } else { if (isset($arrPhotoIds[$arrSize - 1])) { $this->view->prevId = $arrPhotoIds[$arrSize - 1]; } } /*------------------ CHECK LIKED-UNLIKED ALBUM ------------------*/ $whereVote = "item_type='album_photo' AND item_id='{$photoId}' AND user_id='{$loggedInUserId}' AND vote='1'"; $arrVote = $objModelVote->fetchAll($whereVote); if (count($arrVote) > 0) { $this->view->numVote = 1; } else { $this->view->numVote = 0; } }
public function oldemployeeAttendanceAction() { $userId = $this->_getParam('id'); $model1 = new Application_Model_User(); $model = $model1->find($userId); if (false === $model) { $this->_flashMessenger->addMessage(array('error' => 'Invalid request! Please try again.')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/employees')); } $this->view->user = $model; $request = $this->getRequest(); $form = new Application_Form_Attendance(); $form->removeElement("attendanceSheet"); $form->clearDecorators(); $elements = $form->getElements(); foreach ($elements as $element) { $element->setAttrib("style", "width:100px"); $element->removeDecorator('label'); } $form->getElement("month")->setAttrib("class", ""); $form->getElement("year")->setAttrib("class", ""); if ($request->isPost()) { $options = $request->getPost(); if ($form->isValid($options)) { $date = $options["year"] . "-" . $options['month']; $attendance = new Application_Model_Attendance(); $this->view->attendance = $attendance->fetchAll("user_id='{$userId}' and DATE_FORMAT(attendance_date, '%Y-%m')='{$date}'"); } else { $form->reset(); $form->populate($options); } } else { $options['month'] = date("m"); $options['year'] = date("Y"); $form->populate($options); $date = date("Y-m"); $attendance = new Application_Model_Attendance(); $this->view->attendance = $attendance->fetchAll("user_id='{$userId}' and DATE_FORMAT(attendance_date, '%Y-%m')='{$date}'"); } $this->view->form = $form; }
public function messageDetailAction() { $id = $this->_getParam('id'); $id = base64_decode($id); /*------------ MARKED AS READ --------------------*/ $modelMessages = new Application_Model_Message(); $modelUser = new Application_Model_User(); $valMessages = $modelMessages->find($id); $option['read'] = 1; $valMessages->setOptions($option); $savemsg = $valMessages->save(); $messageSenderId = $valMessages->getFromId(); $valUser = $modelUser->find($messageSenderId); $senderName = $valUser->getUsername(); /*------------------------------------------------*/ $valMessage = $modelMessages->find($id); $this->view->body = nl2br(stripslashes($valMessage->getBody())); $this->view->subject = $valMessage->getSubject(); $this->view->addedon = date("dS M Y", $valMessage->getAddedDate()); $this->view->senderName = $senderName; $this->view->msgId = base64_encode($id); }
public function addAsFriend($sender_id, $user_id) { $senderM = new Application_Model_User(); if ($senderM->find($sender_id)) { $this->setFriendId($user_id); $this->setUserId($sender_id); $this->setStatus("accept"); $this->setConnectionType("friend"); $this->save(); } }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 27-Dec-2010 * @Description: Used to delete user(simply change user status as 'deleted') */ public function deleteAction() { $id = $this->_getParam('id'); $page = $this->_getParam('page'); $userM = new Application_Model_User(); if (false !== $userM) { $userR = $userM->find($id); $userR->setStatus('deleted'); $userR->save(); //delete user data $userM->deleteUserData($userR->getId()); //redirect user to index $this->_helper->redirector('index', 'user', "admin", array('page' => $page, 'msg' => base64_encode("User [Id : {$userR->getId()}] has been deleted!"))); } else { $this->_helper->redirector('index', 'user', "admin", array('msg' => base64_encode("Invalid request. No user exists."))); } }
public function getAllAlbumComment($albumId, $item_type) { $objModelComment = new Application_Model_Comment(); $objModelUser = new Application_Model_User(); $arrAllComment = array(); $whereComment = "parent_id='0' AND item_type='{$item_type}' AND item_id='{$albumId}' AND publish='1'"; $orderComment = "addedon DESC"; $arrComment = $objModelComment->fetchAll($whereComment, $orderComment); $i = 0; foreach ($arrComment as $com) { $userId = $com->userId; $valUser = $objModelUser->find($userId); $arrAllComment[$i]['commenterName'] = $valUser->getFirstName() . ' ' . $valUser->getLastName(); $arrAllComment[$i]['imageName'] = $valUser->getImage(); $arrAllComment[$i]['comment'] = nl2br(stripslashes($com->comment)); $arrAllComment[$i]['commentId'] = stripslashes($com->id); $arrAllComment[$i]['addedon'] = date("D, M j, Y", $com->addedon); $i++; } return $arrAllComment; }
public function detailAction() { $id = $this->_getParam("id"); $preview = false; $preview = $this->_getParam("preview"); $adviceM = new Application_Model_Advice(); $adviceM = $adviceM->find($id); if (false !== $adviceM) { $this->view->advice = $adviceM; $this->view->preview = $preview; //display advices in right block associated with this category $this->view->category_id = $category_id = $adviceM->getCategoryId(); $categoryM = new Application_Model_Category(); $categoryM = $categoryM->find($category_id); $cat_name = ""; if (false !== $categoryM) { $cat_name = $categoryM->getName(); $this->view->cat_name = $cat_name; } /** * @Added By: Mahipal Adhikari * @Added On: 1-Mar-2011 * @Description: get Article user information to display as Author */ $userM = new Application_Model_User(); $userRes = $userM->find($adviceM->getUserId()); $Author = "Admin"; if (false !== $userRes) { $Author = $userRes->getFirstName() . " " . $userRes->getLastName(); $this->view->author = $Author; $this->view->author_username = $userRes->getUsername(); } } //end if }