Пример #1
0
 /**
  * Implementation of the singleton design pattern
  * See http://www.talkphp.com/advanced-php-programming/1304-how-use-singleton-design-pattern.html
  * 
  * @return SessionWrapper
  */
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Пример #2
0
 public function loginAction()
 {
     $userForm = new Form_LoginForm();
     $userForm->setAction('/auth/login');
     if ($this->_request->isPost() && $userForm->isValid($_POST)) {
         $data = $userForm->getValues();
         $db = Zend_Db_Table::getDefaultAdapter();
         $authAdapter = new Zend_Auth_Adapter_DbTable($db, 'utils', 'username', 'source');
         $authAdapter->setIdentity($data['username']);
         $authAdapter->setCredential($data['password']);
         $result = $authAdapter->authenticate();
         if ($result->isValid()) {
             $auth = Zend_Auth::getInstance();
             $data1 = $authAdapter->getResultRowObject(null, 'source');
             // $auth->getStorage()->write($data1);
             // $auth->getStorage()->write($data);
             $dom = $auth->getIdentity()->domainadmin;
             $host = $auth->getIdentity()->hostadmin;
             $mySession = SessionWrapper::getInstance();
             $mySession->setSessVar('username', $formData['username']);
             date_default_timezone_set('Europe/Brussels');
             echo 'valid';
         } else {
             $this->view->loginMessage = "Sorry, your username or password was incorrect";
         }
     }
     $this->view->form = $userForm;
 }
Пример #3
0
 function processPost($formvalues)
 {
     $session = SessionWrapper::getInstance();
     // trim spaces from the name field
     if (isArrayKeyAnEmptyString('create', $formvalues)) {
         $formvalues['create'] = 0;
     }
     if (isArrayKeyAnEmptyString('edit', $formvalues)) {
         $formvalues['edit'] = 0;
     }
     if (isArrayKeyAnEmptyString('view', $formvalues)) {
         $formvalues['view'] = 0;
     }
     if (isArrayKeyAnEmptyString('list', $formvalues)) {
         $formvalues['list'] = 0;
     }
     if (isArrayKeyAnEmptyString('delete', $formvalues)) {
         $formvalues['delete'] = 0;
     }
     if (isArrayKeyAnEmptyString('export', $formvalues)) {
         $formvalues['export'] = 0;
     }
     if (isArrayKeyAnEmptyString('approve', $formvalues)) {
         $formvalues['approve'] = 0;
     }
     if (isArrayKeyAnEmptyString('flag', $formvalues)) {
         $formvalues['flag'] = 0;
     }
     // debugMessage($formvalues); exit();
     parent::processPost($formvalues);
 }
Пример #4
0
 public static function initialize()
 {
     if (self::$initialized) {
         return;
     }
     self::$initialized = true;
     try {
         // Initialize local session
         Session::init();
         if (!empty($_GET['logout'])) {
             self::destroy();
             Session::init();
         }
         if (!Session::userIsLoggedIn() && Request::cookie('remember_me')) {
             if (!LoginModel::loginWithCookie(Request::cookie('remember_me'))) {
                 LoginModel::deleteCookie();
             }
         }
         $currentUrl = $_SERVER['REQUEST_URI'];
         $end = strpos($currentUrl, '?');
         if ($end === false) {
             $end = strpos($currentUrl, '#');
         }
         if ($end !== false) {
             $currentUrl = substr($currentUrl, 0, $end);
         }
         // Initialize Facebook session
         /*self::$facebookSession = new FacebookSessionWrapper(
             Tools::getBaseUrl() . $currentUrl,
             Tools::getBaseUrl() . '/logout/'
           );*/
     } catch (\Exception $ex) {
     }
 }
Пример #5
0
 function updatestatusAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $formvalues = $this->_getAllParams();
     debugMessage($formvalues);
     $session = SessionWrapper::getInstance();
     $this->_translate = Zend_Registry::get("translate");
     $formvalues['id'] = $id = $formvalues['id'];
     $formvalues['dateapproved'] = date("Y-m-d H:i:s", strtotime('now'));
     $formvalues['approvedbyid'] = $session->getVar('userid');
     // debugMessage($formvalues);
     $leave = new Leave();
     $leave->populate($id);
     $leave->setStatus($formvalues['status']);
     $leave->setDateApproved(DEFAULT_DATETIME);
     $leave->setApprovedByID($session->getVar('userid'));
     if (!isArrayKeyAnEmptyString('reason', $formvalues)) {
         $leave->setReason("<br/>Rejected with remarks: " . $formvalues['reason']);
     }
     try {
         $leave->save();
         $leave->afterApprove($formvalues['status']);
         $session->setVar(SUCCESS_MESSAGE, $this->_translate->translate($formvalues[SUCCESS_MESSAGE]));
     } catch (Exception $e) {
         // debugMessage('error '.$e->getMessage());
         $session->setVar(ERROR_MESSAGE, $e->getMessage());
     }
     // exit();
     $this->_helper->redirector->gotoUrl(decode($formvalues[URL_SUCCESS]));
 }
 function eventsAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $config = Zend_Registry::get("config");
     $session = SessionWrapper::getInstance();
     $formvalues = $this->_getAllParams();
     $acl = getACLInstance();
     $user = new UserAccount();
     // $user->populate($formvalues['id']);
     $events = getLeaveRequests("", getYearStart(), getYearEnd());
     // debugMessage($events);
     $jsondata = array();
     $i = 0;
     if (count($events) > 0) {
         // $jsondata = $events;
         $leaveoptions = getHoursDaysDropdown();
         foreach ($events as $key => $value) {
             $jsondata[$key]['id'] = $value['id'];
             $unit = '';
             if (!isArrayKeyAnEmptyString($value['durationtype'], $leaveoptions)) {
                 $unit = ' on Leave';
             }
             $jsondata[$key]['title'] = $value['user'] . $unit;
             $jsondata[$key]['start'] = $value['startdate'];
             $jsondata[$key]['end'] = $value['enddate'];
             if (isTimesheetEmployee() && $value['userid'] == $session->getVar('userid') || $acl->checkPermission('Leave', ACTION_APPROVE)) {
                 // $jsondata[$key]['url'] = $this->view->serverUrl($this->view->baseUrl('leave/view/id/'.encode($value['id'])));
             }
         }
     }
     // debugMessage($jsondata);
     echo json_encode($jsondata);
 }
 function excelAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues);
     $title = $this->_getParam('reporttitle');
     // debugMessage($formvalues);
     $cvsdata = decode($formvalues['csv_text']);
     if (!isEmptyString($title)) {
         $cvsdata = str_replace('"--"', '""', $cvsdata);
         $title = str_replace(', ', ' ', $title);
         $cvsdata = $title . "\r\n" . $cvsdata;
     }
     // debugMessage($cvsdata); exit();
     $currenttime = time();
     $filename = $currenttime . '.csv';
     /*$full_path = BASE_PATH.DIRECTORY_SEPARATOR."temp".DIRECTORY_SEPARATOR.$filename;
     		file_put_contents($full_path, $cvsdata);*/
     $data = stripcslashes($cvsdata);
     // debugMessage($data);
     // exit();
     //OUPUT HEADERS
     header("Pragma: public");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Cache-Control: private", false);
     header("Content-Type: application/octet-stream");
     header("Content-Disposition: attachment; filename=\"{$filename}\";");
     header("Content-Transfer-Encoding: binary");
     //OUTPUT CSV CONTENT
     echo $data;
     exit;
 }
 /**
  * Sends the details of the support form by email 
  */
 public function processcontactusAction()
 {
     $session = SessionWrapper::getInstance();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues);
     $profile = new UserAccount();
     if ($profile->sendContactNotification($formvalues)) {
         // after send events
         $session->setVar(SUCCESS_MESSAGE, "Thank you for contacting us. We shall get back to you shortly.");
         $this->_redirect($this->view->baseUrl('contactus/index/result/success'));
     } else {
         $session->setVar(ERROR_MESSAGE, 'Sorry! An error occured in sending the message. Please try again later ');
         $this->_redirect($this->view->baseUrl('contactus/index/result/error'));
     }
 }
Пример #9
0
 public function init()
 {
     // initialize the parent controller
     parent::init();
     $session = SessionWrapper::getInstance();
     // check whether the user is logged in
     if (isEmptyString($session->getVar('userid'))) {
         // clear the session
         $this->_helper->redirector->gotoSimpleAndExit("login", "user", $this->getRequest()->getModuleName(), array('redirecturl' => encode(Zend_Controller_Front::getInstance()->getRequest()->getRequestUri())));
     }
     $cache = Zend_Registry::get('cache');
     // load the acl instance
     $acl = getACLInstance();
     // debugMessage('resource is '.$this->getResourceForACL()." action ".$this->getActionforACL()); exit;
     if (!$acl->checkPermission($this->getResourceForACL(), $this->getActionforACL())) {
         // debugMessage('resource is '.$this->getResourceForACL()." action ".$this->getActionforACL());
         // redirect to the access denied page
         $this->_helper->redirector->gotoSimpleAndExit("accessdenied", "index");
     }
 }
Пример #10
0
 function checkinAction()
 {
     $session = SessionWrapper::getInstance();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $formvalues = $this->_getAllParams();
     debugMessage('test');
     $testarray = array("userid" => 15, 'datein' => 'Jan 27, 2015', 'timein' => '08:00 AM', 'dateout' => '', 'timeout' => '', 'reason' => '', 'createdby' => 15);
     $attendance = new Attendance();
     debugMessage($attendance->toArray());
     $attendance->processPost($testarray);
     debugMessage($attendance->toArray());
     debugMessage('errors are ' . $attendance->getErrorStackAsString());
     try {
         $attendance->save();
         debugMessage('saved successfully');
         debugMessage($attendance->toArray());
     } catch (Exception $e) {
         debugMessage('error: ' . $e->getMessage());
     }
 }
 public function uploadAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues);
     $config = Zend_Registry::get("config");
     $this->_translate = Zend_Registry::get("translate");
     $session = SessionWrapper::getInstance();
 }
 function processreplyAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $config = Zend_Registry::get("config");
     $formvalues = $this->_getAllParams();
     debugMessage($formvalues);
     $messages = array();
     $messages['senderid'] = $formvalues['senderid'];
     $messages['parentid'] = $formvalues['parentid'];
     $messages['subject'] = $formvalues['subject'];
     $messages['contents'] = $formvalues['contents'];
     $recipients_array = array();
     $users = array();
     $users = $formvalues['recipientids'];
     foreach ($users as $userid) {
         $recipients_array[$userid]['recipientid'] = $userid;
     }
     $messages['recipients'] = $recipients_array;
     // debugMessage($messages);
     $msg = new Message();
     $msg->processPost($messages);
     /*debugMessage($msg->toArray());
     		debugMessage('error is '.$msg->getErrorStackAsString()); exit();*/
     // save the messages to system inbox
     if ($msg->hasError()) {
         $session->setVar(ERROR_MESSAGE, "An error occured in sending the message. " . $msg->getErrorStackAsString());
     } else {
         try {
             $msg->save();
             // copy message to recepient's email of specified  / required for admin contact
             $messagereceipients = $msg->getRecipients();
             if ($this->_getParam('copytoemail') == 1) {
                 foreach ($messagereceipients as $messageuser) {
                     if (!isEmptyString($messageuser->getRecipient()->getEmail())) {
                         $messageuser->sendInboxEmailNotification();
                     }
                 }
             }
             if ($this->_getParam('copytophone') == 1) {
                 foreach ($messagereceipients as $messageuser) {
                     if (!isEmptyString($messageuser->getRecipient()->getPhone())) {
                         # check if user has phone number on profile
                         $messageuser->sendSmsNotification();
                     }
                 }
             }
             // copy message to user's phone if specified
             $session->setVar(SUCCESS_MESSAGE, "Message successfully replied. ");
         } catch (Exception $e) {
             $session->setVar(ERROR_MESSAGE, "An error occured in sending the message. " . $e->getMessage());
         }
     }
     $this->_helper->redirector->gotoUrl(decode($formvalues[URL_SUCCESS]));
     // exit();
 }
Пример #13
0
 function schedulecreateAction()
 {
     $session = SessionWrapper::getInstance();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     // parent::createAction();
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues); exit();
     $formvalues['id'] = $id = decode($formvalues['id']);
     $status = $formvalues['status'];
     $old_shift = $formvalues['shift_old'];
     $isactive = false;
     $shift = new ShiftSchedule();
     if (!isArrayKeyAnEmptyString('id', $formvalues)) {
         $shift->populate($id);
         $isactive = $shift->isActive();
     } else {
         $formvalues['addedbyid'] = $session->getVar('userid');
         $formvalues['dateadded'] = DEFAULT_DATETIME;
     }
     $shift->processPost($formvalues);
     if ($shift->hasError()) {
         debugMessage('errors are ' . $shift->getErrorStackAsString());
         exit;
         $session->setVar(ERROR_MESSAGE, $shift->getErrorStackAsString());
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
         exit;
     }
     // exit;
     try {
         $updateshift = false;
         if ($status == 1) {
             if ($old_shift != $shift->getSessionID()) {
                 $shift->getUser()->setShift($shift->getSessionID());
                 $updateshift = true;
             }
         } else {
             if (!isEmptyString($old_shift) && $isactive) {
                 $shift->getUser()->setShift(NULL);
                 $updateshift = true;
             }
         }
         // debugMessage($shift->toArray()); exit;
         $shift->save();
         # update any previous shifts that could still be active when setting a new active session
         if ($status == 1) {
             $updateableshifts = $shift->getCurrentActiveShiftsForUser($shift->getUserID());
             // debugMessage($updateableshifts->toArray());
             if ($updateableshifts->count() > 0) {
                 foreach ($updateableshifts as $ashift) {
                     $ashift->setStatus(0);
                     $ashift->save();
                 }
             }
         }
         $session->setVar(SUCCESS_MESSAGE, $this->_getParam('successmessage'));
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_SUCCESS)));
     } catch (Exception $e) {
         $session->setVar(ERROR_MESSAGE, $e->getMessage());
         //debugMessage('save error '.$e->getMessage());
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
 }
Пример #14
0
 function sendApprovalConfirmationNotification()
 {
     $template = new EmailTemplate();
     # create mail object
     $mail = getMailInstance();
     $view = new Zend_View();
     $session = SessionWrapper::getInstance();
     // assign values
     $template->assign('firstname', $this->getUser()->getFirstName());
     $statuslabel = $this->isApproved() ? "Approved" : "Rejected";
     $subject = "Leave " . $statuslabel;
     $save_toinbox = true;
     $type = "leave";
     $subtype = "leave_" . strtolower($statuslabel);
     $viewurl = $template->serverUrl($template->baseUrl('leave/view/id/' . encode($this->getID())));
     $rejectreason = "";
     if ($this->isRejected()) {
         $rejectreason = "<br><b>Synopsis:</b> " . $this->getComments() . "";
     }
     $days = $this->getDuration() / getHoursInDay();
     $message_contents = "<p>This is to confirm that your Leave Request from <b>" . changeMySQLDateToPageFormat($this->getStartDate()) . "</b> to <b> " . changeMySQLDateToPageFormat($this->getEndDate()) . "</b> has been successfully " . $statuslabel . $rejectreason . ".</p>\n\t\t<p>To view your request online <a href='" . $viewurl . "'>click here<a></p>\n\t\t<br />\n\t\t<p>" . $this->getApprover()->getName() . "<br />\n\t\t" . getAppName() . "</p>\n\t\t";
     $template->assign('contents', $message_contents);
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     // configure base stuff
     $mail->addTo($this->getUser()->getEmail(), $this->getUser()->getName());
     // set the send of the email address
     $mail->setFrom(getDefaultAdminEmail(), getDefaultAdminName());
     $mail->setSubject($subject);
     // render the view as the body of the email
     $html = $template->render('default.phtml');
     $mail->setBodyHtml($html);
     // debugMessage($html); exit();
     if ($this->getUser()->allowEmailForTimesheetApproval() && !isEmptyString($this->getUser()->getEmail())) {
         try {
             $mail->send();
             $session->setVar("custommessage1", "Email sent to " . $this->getUser()->getEmail());
         } catch (Exception $e) {
             $session->setVar(ERROR_MESSAGE, 'Email notification not sent! ' . $e->getMessage());
         }
     }
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     $mail->clearFrom();
     if ($save_toinbox) {
         # save copy of message to user's application inbox
         $message_dataarray = array("senderid" => DEFAULT_ID, "subject" => $subject, "contents" => $message_contents, "html" => $html, "type" => $type, "subtype" => $subtype, "refid" => $this->getID(), "recipients" => array(md5(1) => array("recipientid" => $this->getUserID())));
         // debugMessage($message_dataarray);
         // process message data
         $message = new Message();
         $message->processPost($message_dataarray);
         $message->save();
     }
     return true;
 }
Пример #15
0
 function sendPayslipNotification()
 {
     $template = new EmailTemplate();
     # create mail object
     $mail = getMailInstance();
     $view = new Zend_View();
     $session = SessionWrapper::getInstance();
     // assign values
     $template->assign('firstname', $this->getUser()->getFirstName());
     $subject = "Payslip " . date('F Y', strtotime($this->getPayroll()->getStartDate()));
     $save_toinbox = true;
     $type = "payroll";
     $subtype = "payslip_generated";
     $viewurl = $template->serverUrl($template->baseUrl('temp/' . $this->getPDFName() . '.pdf'));
     $message_contents = "<p>This is to confirm that your Payslip for <b>" . date('F Y', strtotime($this->getPayroll()->getStartDate())) . "</b> has been completed and attached.</p>\n\t\t<p>You can also view it online <a href='" . $viewurl . "'>click here<a></p>\n\t\t<br />\n\t\t<p>" . $this->getPayroll()->getCreator()->getName() . "<br />\n\t\t" . getAppName() . "</p>\n\t\t";
     $template->assign('contents', $message_contents);
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     // configure base stuff
     $mail->addTo($this->getUser()->getEmail(), $this->getUser()->getName());
     // set the send of the email address
     $mail->setFrom(getDefaultAdminEmail(), getDefaultAdminName());
     $mail->setSubject($subject);
     // add attachment
     $content = file_get_contents($this->getPDFPath());
     // e.g. ("attachment/abc.pdf")
     $attachment = new Zend_Mime_Part($content);
     $attachment->type = 'application/pdf';
     $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
     $attachment->encoding = Zend_Mime::ENCODING_BASE64;
     $attachment->filename = $this->getPDFName();
     // name of file
     $mail->addAttachment($attachment);
     // render the view as the body of the email
     $html = $template->render('default.phtml');
     $mail->setBodyHtml($html);
     // debugMessage($html); // exit();
     if ($this->getUser()->allowEmailForPayslip() && !isEmptyString($this->getUser()->getEmail())) {
         try {
             $mail->send();
             // $session->setVar("custommessage1", "Email sent to ".$this->getUser()->getEmail());
         } catch (Exception $e) {
             debugMessage('Email notification not sent! ' . $e->getMessage());
             $session->setVar(ERROR_MESSAGE, 'Email notification not sent! ' . $e->getMessage());
         }
     }
     $mail->clearRecipients();
     $mail->clearSubject();
     $mail->setBodyHtml('');
     $mail->clearFrom();
     if ($save_toinbox) {
         # save copy of message to user's application inbox
         $message_dataarray = array("senderid" => DEFAULT_ID, "subject" => $subject, "contents" => $message_contents, "html" => $html, "type" => $type, "subtype" => $subtype, "refid" => $this->getID(), "recipients" => array(md5(1) => array("recipientid" => $this->getUserID())));
         // debugMessage($message_dataarray);
         // process message data
         $message = new Message();
         $message->processPost($message_dataarray);
         $message->save();
     }
     return true;
 }
Пример #16
0
 /**
  * Action to display the Login page 
  */
 public function logoutAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $browser = new Browser();
     $audit_values = $session->getVar('browseraudit');
     $audit_values['module'] = 1;
     $audit_values['usecase'] = '1.2';
     $audit_values['transactiontype'] = USER_LOGOUT;
     $audit_values['status'] = "Y";
     $audit_values['userid'] = $session->getVar('userid');
     $audit_values['transactiondetails'] = "Logout for user with id '" . $session->getVar('username') . "' successful";
     // debugMessage($audit_values);
     $this->notify(new sfEvent($this, USER_LOGIN, $audit_values));
     $this->clearSession();
     // redirect to the login page
     $this->_helper->redirector->gotoUrl($this->view->baseUrl("user/login"));
 }
	public static function getId() {
		if (null === self::$_instance) {
            self::$_instance = new self();
        }
        return Zend_Session::getId();
    }
Пример #18
0
 public static function startSession()
 {
     if (self::$sessionStarted) {
         return;
     }
     self::$sessionStarted = true;
     SessionWrapper::initialize();
     // language
     $_SESSION['lang'] = 'es';
 }
Пример #19
0
 /**
  * Overide  to save persons relationships
  *	@return true if saved, false otherwise
  */
 function afterSave()
 {
     $session = SessionWrapper::getInstance();
     $conn = Doctrine_Manager::connection();
     $update = false;
     # save changes
     if ($update) {
         $this->save();
     }
     // find any duplicates and delete them
     $duplicates = $this->getDuplicates();
     if ($duplicates->count() > 0) {
         $duplicates->delete();
     }
     // exit();
     return true;
 }
Пример #20
0
 function isTimesheetEmployee()
 {
     $session = SessionWrapper::getInstance();
     $acl = getACLInstance();
     return $this->getType() == '2' && ($this->getIsTimesheetuser() == '1' || $this->getIsTimesheetuser() == '2') ? true : false;
 }
Пример #21
0
        Tools::lang(array('es' => 'Enviar', 'en' => 'Submit'));
        ?>
"/>
              </div>
            </form>
          <?php 
    } else {
        SessionWrapper::clearFeedback();
        if ($_SESSION['lang'] == 'en') {
            echo '<h3>Your password has been updated.</h3>';
            echo '<h3>Now you can <a href="' . Tools::getBaseUrl(true) . '/login/">log in</a>.</h3>';
        } else {
            echo '<h3>Su contraseña ha sido actualizada.</h3>';
            echo '<h3>Ahora puede <a href="' . Tools::getBaseUrl(true) . '/login/">iniciar sesión</a>.</h3>';
        }
    }
} else {
    SessionWrapper::clearFeedback();
    if ($_SESSION['lang'] == 'en') {
        echo '<h3>Your password reset code has expired.</h3>';
        echo '<h3>Please <a href="' . Tools::getBaseUrl(true) . '/recuperar-cuenta/">request a new one</a>.</h3>';
    } else {
        echo '<h3>El código para reestablecer su contraseña ha expirado.</h3>';
        echo '<h3>Por favor <a href="' . Tools::getBaseUrl(true) . '/recuperar-cuenta/">solicite uno nuevo</a>.</h3>';
    }
}
?>
      </main>

<?php 
require_once '../footer.php';
Пример #22
0
 public function processrolesAction()
 {
     $session = SessionWrapper::getInstance();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $this->_translate = Zend_Registry::get("translate");
     $post_array = $this->_getAllParams();
     // debugMessage($this->_getAllParams()); exit;
     $id = $post_array['id'];
     $post_array['id'] = decode($id);
     $perms = $post_array['permissions'];
     unset($post_array['permissions']);
     if (isEmptyString($id)) {
         // add new role first
         $newrole = new AclGroup();
         $post_array['createdby'] = $session->getVar('userid');
         $newrole->processPost($post_array);
         // debugMessage($newrole->toArray()); debugMessage('error is '.$newrole->getErrorStackAsString());
         $newrole->save();
         $post_array['id'] = $newrole->getID();
     } else {
         // update role first
         $newrole = new AclGroup();
         $newrole->populate(decode($id));
         $newrole->processPost($post_array);
         // debugMessage($newrole->toArray()); debugMessage('error is '.$newrole->getErrorStackAsString()); // exit();
         $newrole->save();
     }
     // exit;
     $role = new AclGroup();
     $role->populate($post_array['id']);
     $permissions = $role->getPermissions();
     $permissions_array = $permissions->toArray();
     $post_array['permissions'] = $perms;
     // set audit entry before save
     if (!isArrayKeyAnEmptyString('permissions', $post_array)) {
         $data = array();
         foreach ($post_array['permissions'] as $key => $value) {
             $data[$key] = $value;
             $post_array['permissions'][$key]['groupid'] = $post_array['id'];
             if (isArrayKeyAnEmptyString('flag', $value)) {
                 $post_array['permissions'][$key]['flag'] = 0;
             } else {
                 $post_array['permissions'][$key]['flag'] = trim(intval($value['flag']));
             }
             if (isArrayKeyAnEmptyString('create', $value)) {
                 $post_array['permissions'][$key]['create'] = 0;
             } else {
                 $post_array['permissions'][$key]['create'] = trim(intval($value['create']));
             }
             if (isArrayKeyAnEmptyString('edit', $value)) {
                 $post_array['permissions'][$key]['edit'] = 0;
             } else {
                 $post_array['permissions'][$key]['edit'] = trim(intval($value['edit']));
             }
             if (isArrayKeyAnEmptyString('view', $value)) {
                 $post_array['permissions'][$key]['view'] = 0;
             } else {
                 $post_array['permissions'][$key]['view'] = trim(intval($value['view']));
             }
             if (isArrayKeyAnEmptyString('list', $value)) {
                 $post_array['permissions'][$key]['list'] = 0;
             } else {
                 $post_array['permissions'][$key]['list'] = trim(intval($value['list']));
             }
             if (isArrayKeyAnEmptyString('delete', $value)) {
                 $post_array['permissions'][$key]['delete'] = 0;
             } else {
                 $post_array['permissions'][$key]['delete'] = trim(intval($value['delete']));
             }
             if (isArrayKeyAnEmptyString('approve', $value)) {
                 $post_array['permissions'][$key]['approve'] = 0;
             } else {
                 $post_array['permissions'][$key]['approve'] = trim(intval($value['approve']));
             }
             if (isArrayKeyAnEmptyString('export', $value)) {
                 $post_array['permissions'][$key]['export'] = 0;
             } else {
                 $post_array['permissions'][$key]['export'] = trim(intval($value['export']));
             }
             if (isArrayKeyAnEmptyString('id', $value)) {
                 $post_array['permissions'][$key]['id'] = NULL;
             }
             $post_array['permissions'][$key]['createdby'] = $session->getVar('userid');
             $post_array['permissions'][$key]['datecreated'] = getCurrentMysqlTimestamp();
             if (!isArrayKeyAnEmptyString('id', $value)) {
                 $post_array['permissions'][$key]['lastupdatedby'] = $session->getVar('userid');
                 $post_array['permissions'][$key]['lastupdatedate'] = getCurrentMysqlTimestamp();
             } else {
                 $post_array['createdby'] = $session->getVar('userid');
             }
         }
         // end loop through permissions to unset empty groupids
     }
     // debugMessage($post_array); exit();
     if (!isEmptyString($id)) {
         $beforesave = $post_array['permissions'];
         // debugMessage($beforesave);
     }
     $perm_collection = new Doctrine_Collection(Doctrine_Core::getTable("AclPermission"));
     foreach ($post_array['permissions'] as $key => $value) {
         $perm = new AclPermission();
         if (!isArrayKeyAnEmptyString('id', $value)) {
             $perm->populate($value['id']);
         }
         $perm->processPost($value);
         if ($perm->isValid()) {
             $perm_collection->add($perm);
         } else {
             debugMessage('Error: ' . $perm->getErrorStackAsString());
             exit;
         }
     }
     try {
         $perm_collection->save();
         if (isEmptyString($id)) {
             # add log to audit trail
             $url = $this->view->serverUrl($this->view->baseUrl('role/view/id/' . encode($newrole->getID())));
             $usecase = '0.4';
             $module = '0';
             $type = SYSTEM_CREATEROLE;
             $details = "Role <a href='" . $url . "' class='blockanchor'>" . $newrole->getName() . "</a> created";
         } else {
             $url = $this->view->serverUrl($this->view->baseUrl('role/view/id/' . encode($newrole->getID())));
             $usecase = '0.5';
             $module = '0';
             $type = SYSTEM_UPDATEROLE;
             $details = "Role <a href='" . $url . "' class='blockanchor'>" . $newrole->getName() . "</a> updated";
             $prejson = json_encode($beforesave);
             $after = $perm_collection->toArray();
             debugMessage($after);
             $postjson = json_encode($post_array);
             // debugMessage($postjson);
             // $diff = array_diff($beforesave, $after);  // debugMessage($diff);
             $jsondiff = '';
             // debugMessage($jsondiff);
         }
         $browser = new Browser();
         $audit_values = $session->getVar('browseraudit');
         $audit_values['module'] = $module;
         $audit_values['usecase'] = $usecase;
         $audit_values['transactiontype'] = $type;
         $audit_values['status'] = "Y";
         $audit_values['userid'] = $session->getVar('userid');
         $audit_values['transactiondetails'] = $details;
         $audit_values['url'] = $url;
         if (!isEmptyString($id)) {
             $audit_values['isupdate'] = 1;
             $audit_values['prejson'] = $prejson;
             $audit_values['postjson'] = $postjson;
             $audit_values['jsondiff'] = $jsondiff;
         }
         // debugMessage($audit_values);
         $this->notify(new sfEvent($this, $type, $audit_values));
         if (!isEmptyString($this->_getParam(SUCCESS_MESSAGE))) {
             $session->setVar(SUCCESS_MESSAGE, $this->_translate->translate($this->_getParam(SUCCESS_MESSAGE)));
         }
         $this->_helper->redirector->gotoUrl($this->view->baseUrl("role/view/id/" . encode($role->getID())));
     } catch (Exception $e) {
         // debugMessage($perm_collection->toArray());
         // debugMessage('error in save. '.$e->getMessage());
         $session->setVar(ERROR_MESSAGE, $e->getMessage());
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
 }
Пример #23
0
 function afterSave()
 {
     $session = SessionWrapper::getInstance();
     # add log to audit trail
     $view = new Zend_View();
     $url = $view->serverUrl($view->baseUrl('role/view/id/' . encode($this->getID())));
     $usecase = '0.4';
     $module = '0';
     $type = SYSTEM_CREATEROLE;
     $details = "Role <a href='" . $url . "' class='blockanchor'>" . $this->getName() . "</a> created";
     $browser = new Browser();
     $audit_values = $session->getVar('browseraudit');
     $audit_values['module'] = $module;
     $audit_values['usecase'] = $usecase;
     $audit_values['transactiontype'] = $type;
     $audit_values['status'] = "Y";
     $audit_values['userid'] = $session->getVar('userid');
     $audit_values['transactiondetails'] = $details;
     $audit_values['url'] = $url;
     // debugMessage($audit_values);
     $this->notify(new sfEvent($this, $type, $audit_values));
 }
Пример #24
0
    function indexAction()
    {
        $session = SessionWrapper::getInstance();
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(TRUE);
        $conn = Doctrine_Manager::connection();
        $formvalues = $this->_getAllParams();
        $userid = $session->getVar('userid');
        $companyid = getCompanyID();
        $acl = getACLInstance();
        $company_query = "";
        $company_query = " u.companyid = '" . $companyid . "' AND ";
        $q = $formvalues['searchword'];
        $html = '';
        $hasdata = false;
        // )
        # search users if loggedin user has access
        if ($acl->checkPermission('User Account', ACTION_LIST)) {
            $query = "SELECT u.id FROM useraccount as u \n\t\t\t\tWHERE " . $company_query . "\n\t\t\t   (u.firstname like '%" . $q . "%' or \n\t\t\t\tu.lastname like '%" . $q . "%' or \n\t\t\t\tu.othername like '%" . $q . "%' or \n\t\t\t\tu.displayname like '%" . $q . "%' or \n\t\t\t\tu.email like '%" . $q . "%' or \n\t\t\t\tu.phone like '%" . $q . "%' or \n\t\t\t\tu.username like '%" . $q . "%') \n\t\t\t\tGROUP BY u.id\n\t\t\t\torder by u.displayname asc LIMIT 5 ";
            // debugMessage($query);
            $result = $conn->fetchAll($query);
            $count_results = count($result);
            // debugMessage($result);
            if ($count_results > 0) {
                $hasdata = true;
                $html .= '<div class="separator"><span>Employees</span>
					<div class="allresults"><a href="' . $this->view->baseUrl('profile/list/searchterm/' . $q) . '" class="blockanchor">...see more results</a></div>
				</div><ul>';
                foreach ($result as $row) {
                    $user = new UserAccount();
                    $user->populate($row['id']);
                    $b_q = '<b>' . $q . '</b>';
                    $name = $user->getDisplayName();
                    $name = str_ireplace($q, $b_q, $name);
                    $position = getDatavariables('EMPLOYEE_POSITIONS', $user->getPosition(), true);
                    $phone = $user->getPhone();
                    $phone = str_ireplace($q, $b_q, $phone);
                    $email = $user->getEmail();
                    $email = str_ireplace($q, $b_q, $email);
                    $media = $user->getMediumPicturePath();
                    $viewurl = $this->view->baseUrl('profile/view/id/' . encode($row['id']));
                    $html .= '
					<li style="height:auto; min-height:90px;" class="display_box" align="left" url="' . $viewurl . '" theid="' . $row['id'] . '">
						<a href="' . $viewurl . '" style="color:#666; text-decoration:none;">
							<img class="imagecontainer" src="' . $media . '" style="width:78px; height:auto; float:left; margin-right:6px;" />
							<div style="margin-left: 70px;">
								<span class="name blocked">' . $name . '</span>
								<span class="name blocked">' . $position . '</span>
								<span class="blocked" style="margin-top:5px;">Email: ' . $email . '</span>
								<span class="blocked">Phone: ' . $phone . '</span>
								
							</div>
						</a>
					</li>';
                }
            }
        }
        # add navigation to searchable parameters
        $result = array('id' => 1, 'users' => '');
        # check no data is available for all areas and return no results message
        if (!$hasdata) {
            $html .= '
				<li class="display_box" align="center" style="height:30px;">
					<span style="width:100%; display:block; text-align:center;">No results for <b>' . $q . '</b></span>
				</li>';
        }
        $html .= '</ul>';
        echo $html;
    }
Пример #25
0
<?php

require_once __DIR__ . '/../classes/SessionWrapper.php';
require_once __DIR__ . '/../classes/Tools.php';
$return = new stdClass();
$return->status = 'error';
// validate the user
if (!SessionWrapper::userIsLoggedIn()) {
    $return->message = 'Por favor inicie sesión.';
    echo json_encode($return);
    return;
}
// retrieve the attachment ID
$attId = !empty($_GET['id']) ? intval($_GET['id']) : null;
if (!$attId) {
    $return->message = 'No se encontró el archivo.';
    echo json_encode($return);
    return;
}
// delete attachment
if (!Tools::deleteNewsAttachment($attId)) {
    $return->message = 'El archivo no pudo eliminarse. Por favor intente de nuevo.';
    echo json_encode($return);
    return;
}
$return->status = 'success';
echo json_encode($return);
Пример #26
0
 function approveAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $config = Zend_Registry::get("config");
     $this->_translate = Zend_Registry::get("translate");
     $formvalues = $this->_getAllParams();
     debugMessage($formvalues);
     $id = decode($formvalues['id']);
     $formvalues['id'] = $id;
     $successmessage = "";
     if (!isArrayKeyAnEmptyString('id', $formvalues)) {
         if (isArrayKeyAnEmptyString('status', $formvalues)) {
             $formvalues['status'] = 1;
         }
         $ledger = new Ledger();
         $ledger->populate($id);
         if (!isArrayKeyAnEmptyString('reason', $formvalues)) {
             $ledger->setRemarks($ledger->getRemarks() . "<br/> Rejected with remarks: " . $formvalues['reason']);
         }
         $ledger->setDateApproved(DEFAULT_DATETIME);
         $ledger->setApprovedByID($session->getVar('userid'));
         $ledger->setStatus($formvalues['status']);
         // debugMessage($ledger->toArray()); exit();
         try {
             $ledger->save();
             $msg = "Successfully Approved";
             if ($formvalues['status'] == 4) {
                 $msg = "Successfully Rejected";
             }
             $session->setVar(SUCCESS_MESSAGE, $msg);
             $ledger->afterApprove();
         } catch (Exception $e) {
             // debugMessage($e->getMessage());
             $session->setVar(ERROR_MESSAGE, $e->getMessage());
         }
     }
     $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_SUCCESS)));
 }
 function smsstatsAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $conn = Doctrine_Manager::connection();
     $session = SessionWrapper::getInstance();
     $query = "SELECT\n\t\tSUM(IF(UNIX_TIMESTAMP(c.datecreated) >= " . $this->view->onehourago_timestamp . ", c.msgcount, 0)) as onehourago,\n\t\tSUM(IF(UNIX_TIMESTAMP(c.datecreated) >= " . $this->view->sixhourago_timestamp . ", c.msgcount, 0)) as sixhourago,\n\t\tSUM(IF(UNIX_TIMESTAMP(c.datecreated) >= " . $this->view->twelvehourago_timestamp . ", c.msgcount, 0)) as twelvehourago,\n\t\tSUM(IF(TO_DAYS(c.datecreated) = TO_DAYS('" . $this->view->today_iso . "'), c.msgcount, 0)) as today,\n\t\tSUM(IF(TO_DAYS(c.datecreated) = TO_DAYS('" . $this->view->yestday_iso . "'), c.msgcount, 0)) as yesterday,\n\t\tSUM(IF(TO_DAYS(c.datecreated) >= TO_DAYS('" . $this->view->mondaythisweek_iso . "') AND TO_DAYS(c.datecreated) <= TO_DAYS('" . $this->view->sundaythisweek_iso . "'), c.msgcount, 0)) as thisweek,\n\t\tSUM(IF(TO_DAYS(c.datecreated) >= TO_DAYS('" . $this->view->mondaylastweek_iso . "') AND TO_DAYS(c.datecreated) <= TO_DAYS('" . $this->view->sundaylastweek_iso . "'), c.msgcount, 0)) as lastweek ,\n\t\tSUM(IF(TO_DAYS(c.datecreated) >= TO_DAYS('" . $this->view->firstdayofthismonth_iso . "') AND TO_DAYS(c.datecreated) <= TO_DAYS('" . $this->view->lastdayofthismonth_iso . "'), c.msgcount, 0)) as thismonth,\n\t\tSUM(IF(TO_DAYS(c.datecreated) >= TO_DAYS('" . $this->view->firstdayoflastmonth_iso . "') AND TO_DAYS(c.datecreated) <= TO_DAYS('" . $this->view->lastdayoflastmonth_iso . "'), c.msgcount, 0)) as lastmonth,\n\t\tSUM(IF(TO_DAYS(c.datecreated) >= TO_DAYS('" . $this->view->firstdayofyear_iso . "') AND TO_DAYS(c.datecreated) <= TO_DAYS('" . $this->view->lastdayofyear_iso . "'), c.msgcount, 0)) as thisyear,\n\t\tSUM(IF(TO_DAYS(c.datecreated) >= TO_DAYS('" . $this->view->firstsystemday_iso . "') AND TO_DAYS(c.datecreated) <= TO_DAYS('" . $this->view->today_iso . "'), c.msgcount, 0)) as allentries\n\t\tFROM outbox AS c\n\t\twhere c.phone <> '' ";
     // debugMessage($query);
     $result = $conn->fetchRow($query);
     // debugMessage($result);
     echo json_encode($result);
 }
Пример #28
0
function getCompanies($status = '1')
{
    $session = SessionWrapper::getInstance();
    $custom_query = "";
    if (!isEmptyString($status)) {
        $custom_query .= " AND c.status = '" . $status . "' ";
    }
    $myquery = "";
    if ($session->getVar('userid') != 81) {
        $myquery = " AND c.createdby <> 81 ";
    }
    $query = "SELECT c.id as optionvalue, c.name as optiontext FROM company c where (c.id <> '' " . $myquery . ") " . $custom_query . " order by optiontext ";
    $array = getOptionValuesFromDatabaseQuery($query);
    return $array;
}
Пример #29
0
function isPublicUser()
{
    $session = SessionWrapper::getInstance();
    return isEmptyString($session->getVar('userid')) ? true : false;
}
Пример #30
0
 function afterUpdate()
 {
     $session = SessionWrapper::getInstance();
     # check if user is being invited during update
     if (!isEmptyString($this->getDefaultUserID()) && isEmptyString($this->getDefaultUser()->getCompanyID())) {
         $this->getDefaultUser()->setCompanyID($this->getID());
         $startdate = DEFAULT_DATETIME;
         $expirydate = date("Y-m-d", strtotime(date("Y-m-d", strtotime($startdate)) . " +" . getTrialDays() . " days "));
         if (isEmptyString($this->getStartDate()) && $this->getID() != DEFAULT_COMPANYID) {
             $this->setStartDate($startdate);
         }
         if (isEmptyString($this->getEndDate()) && $this->getID() != DEFAULT_COMPANYID) {
             $this->setEndDate($expirydate);
         }
         $this->save();
     }
     // invite via email
     if ($this->getIsBeinginvited() == 1) {
         $this->getDefaultUser()->inviteViaEmail();
     }
     if ($this->getID() == DEFAULT_ID) {
         $config_collection = new Doctrine_Collection(Doctrine_Core::getTable("AppConfig"));
         $appconfig = new AppConfig();
         $appconfig->populate(61);
         $appconfig->setOptionValue($this->getAppName());
         $config_collection->add($appconfig);
         $appconfig = new AppConfig();
         $appconfig->populate(62);
         $appconfig->setOptionValue($this->getName());
         $config_collection->add($appconfig);
         if ($config_collection->count() > 0) {
             $config_collection->save();
         }
     }
     return true;
 }