public function __construct($config = array()) { parent::__construct($config = array()); // add the path to the scripts $this->setScriptPath(APPLICATION_PATH . "/views/scripts/email/"); $this->appname = getAppName(); $config = Zend_Registry::get("config"); // default sign off name and email $mail = Zend_Registry::get('mail'); $default_sender = $mail->getDefaultFrom(); //$this->signoffname = $default_sender['name']; //$this->signoffemail = $default_sender['email']; $this->signoffname = getDefaultAdminName(); $this->signoffemail = getDefaultAdminEmail(); $this->contactusurl = $this->serverUrl($this->baseUrl('contactus')); $this->logourl = $this->serverUrl($this->baseUrl('images/logo.jpg')); $this->loginurl = $this->serverUrl($this->baseUrl('user/login')); $this->baseurl = $this->serverUrl($this->baseUrl()); $this->settingsurl = $this->serverUrl($this->baseUrl('profile/view/tab/account')); $allcolors = getAllThemeColors(); //debugMessage($allcolors); $colortxt = getThemeColor(); $themecolor = "blue"; if (!isEmptyString($colortxt)) { $themecolor = $colortxt; } $this->themecolor = $allcolors[$themecolor]; // debugMessage('color is '.$allcolors[$themecolor]); }
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; }
/** * Get the name of the action being accessed * * @return String */ function getActionforACL() { $action = strtolower($this->getRequest()->getActionName()); if ($action == ACTION_INDEX && isEmptyString($this->_getParam('id'))) { return ACTION_CREATE; } if ($action == ACTION_INDEX && !isEmptyString($this->_getParam('id'))) { return ACTION_EDIT; } if ($action == "new") { return ACTION_CREATE; } if ($action == "returntolist") { return ACTION_LIST; } if ($action == "overview") { return ACTION_LIST; } if ($action == "selectchain") { return ACTION_LIST; } if ($action == "listsearch") { return ACTION_LIST; } if ($action == "reject") { return ACTION_APPROVE; } if ($action == "export") { return ACTION_EXPORT; } return $action; }
/** * Return an array containing the ids and names of all parent resources for this resource * * @return Array an array of all parent resources, the key is the id of the resource while the value is the name of the resource */ function getAllParentResources() { $parentquery = "SELECT r.name AS optiontext, r.id AS optionvalue FROM aclresource AS r ORDER BY optiontext"; if (!isEmptyString($this->getID())) { $parentquery .= " AND id <> '" . $this->getID() . "'"; } return getOptionValuesFromDatabaseQuery($parentquery); }
/** * Return the values of the options for the lookup type * * @return Array containing the lookup types for the values or false if an error occurs * */ function getOptionValuesFromQuery() { # get the query to execute $conn = Doctrine_Manager::connection(); $query = $conn->fetchRow("SELECT querystring FROM lookupquery WHERE name = '" . $this->getName() . "'"); # debugMessage($query); if (isEmptyString($query['querystring'])) { return array(); } else { return getOptionValuesFromDatabaseQuery($query['querystring']); } }
function existingPayroll() { $conn = Doctrine_Manager::connection(); # validate unique username and email $id_check = ""; if (!isEmptyString($this->getID())) { $id_check = " AND id <> '" . $this->getID() . "' "; } $companyid = getCompanyID(); $query = "SELECT id FROM payroll p WHERE p.companyid = '" . $companyid . "' AND TO_DAYS(p.startdate) = TO_DAYS('" . $this->getStartDate() . "') AND TO_DAYS(p.enddate) = TO_DAYS('" . $this->getEndDate() . "') AND p.type = '" . $this->getType() . "' " . $id_check; // debugMessage($query); $result = $conn->fetchOne($query); return $result; }
public function connect() { try { if (isEmptyString($this->config['username']) || isEmptyString($this->config['password'])) { $this->connection = new MongoClient(sprintf('mongodb://%s:%d', $this->config['host'], $this->config['port'])); } else { $this->connection = new MongoClient(sprintf('mongodb://%s:%d', $this->config['host'], $this->config['port']), array('username' => $this->config['username'], 'password' => $this->config['password'], 'db' => $this->config['db'])); } } catch (Exception $e) { $this->collection = null; $this->connection = null; Logger::ERROR('Connect mongodb error [' . $e->getMessage() . ']', __FILE__, __LINE__, ERROR_LOG_FILE); } }
/** * 连接数据库 */ public function connect() { try { if (isEmptyString($this->config['username']) || isEmptyString($this->config['password'])) { $this->connection = new MongoClient(sprintf('mongodb://%s:%d', $this->config['host'], $this->config['port'])); } else { $this->connection = new MongoClient(sprintf('mongodb://%s:%d', $this->config['host'], $this->config['port']), array('username' => $this->config['username'], 'password' => $this->config['password'], 'db' => $this->config['db'])); } $this->connection->setReadPreference(MongoClient::RP_SECONDARY_PREFERRED, array()); } catch (Exception $e) { $this->collection = null; $this->connection = null; Logger::write($e->__toString(), ERR); } }
public function __construct($auserid = "") { // do not proceed if no user is defined if (isEmptyString($auserid)) { return; } $conn = Doctrine_Manager::connection(); // initialize the array of available groups $this->availableGroups = array(); // the available actions // get the groups from the database for the specified user $groups = $conn->fetchAll("SELECT groupid FROM aclusergroup WHERE userid = '" . $auserid . "'"); // get the resources from the database $resources = $conn->fetchAll("SELECT id FROM aclresource"); // get the permissions for the specified user // TODO: HM - Remove the need for the c_aclpermission view $permissions = $conn->fetchAll("SELECT `p`.`groupid` AS `groupid`, LOWER(`re`.`name`) AS `resource`, `p`.`create` AS `create`, `p`.`edit` AS `edit`, `p`.`export` AS `export`,`p`.`approve` AS `approve`, `p`.`view` AS `view`, `p`.`delete` AS `delete`, `p`.`list` AS `list`, p.flag as `flag` FROM ((`aclpermission` `p` JOIN `aclresource` `re`) LEFT JOIN `aclusergroup` `ur` ON ((`p`.`groupid` = `ur`.`groupid`))) WHERE ((`p`.`resourceid` = `re`.`id`) AND ur.userid = '" . $auserid . "')"); // add the groups to the ACL foreach ($groups as $value) { $group = new AclGroup(); // load the details of the user group $group->populate($value['groupid']); $this->addRole($group); // add the group to the array of available groups $this->availableGroups[] = $group; } // add the resources to the ACL, the name of the resource and its parent are what are used as identifiers for the resource in the ACL foreach ($resources as $value) { $ares = new AclResource(); $ares->populate($value['id']); $this->add($ares); } // process the permissions for all the actions $allactions = self::getActions(); // add the permissions to the ACL foreach ($permissions as $value) { foreach ($allactions as $theaction) { if ($value[$theaction] == '1') { // the name of the resource is used as a key while the id of the group is used as a key $this->allow($value['groupid'], $value['resource'], $theaction); } } } }
function valueExists($value = '') { $conn = Doctrine_Manager::connection(); $id_check = ""; if (!isEmptyString($this->getID())) { $id_check = " AND id <> '" . $this->getID() . "' "; } if (isEmptyString($value)) { $value = $this->getlookupvaluedescription(); } # unique value $value_query = "SELECT id FROM lookuptypevalue WHERE lookupvaluedescription = '" . $value . "' AND lookuptypeid = '" . $this->getLookupTypeID() . "' AND alias = '" . $this->getAlias() . "' " . $id_check; // debugMessage($value_query); $value_result = $conn->fetchOne($value_query); // debugMessage($value_result); if (isEmptyString($value_result)) { return false; } return true; }
function nameExists($name = '') { $conn = Doctrine_Manager::connection(); # validate unique username and email $id_check = ""; if (!isEmptyString($this->getID())) { $id_check = " AND id <> '" . $this->getID() . "' "; } if (isEmptyString($name)) { $name = $this->getName(); } $query = "SELECT id FROM benefittype WHERE name = '" . $name . "' AND name <> '' " . $id_check; // debugMessage($query); $result = $conn->fetchOne($query); // debugMessage($result); if (isEmptyString($result)) { return false; } return true; }
/** * Return a URL based on whether there were errors while processing the relevant action. * * The url forwarded to can be overridden by specifying the sucessurl and failure url properties * * @return String the url to which to forward based on whether or not the action was successful. */ function getUrl() { if ($this->hasError()) { if (isEmptyString($this->getFailureURL())) { return "../" . $this->getModuleName() . "/create" . $this->getEntityName() . ".php?id=" . $this->getID() . "&action=" . $this->getAction() . "&modifier=" . $this->getModifier(); } else { return $this->getFailureURL(); } } else { if (isEmptyString($this->getSuccessURL())) { return "../" . $this->getModuleName() . "/view" . $this->getEntityName() . ".php?id=" . $this->getID() . "&modifier=" . $this->getModifier(); } else { // check if the success url contains a query string $separator = "&"; if (strpos($this->getSuccessURL(), "?") === false) { // do nothing $separator = "?"; } return $this->getSuccessURL() . $separator . "id=" . $this->getID(); } } }
function processchangepasswordAction() { $session = SessionWrapper::getInstance(); $this->_translate = Zend_Registry::get("translate"); if (!isEmptyString($this->_getParam('password'))) { $user = new UserAccount(); $user->populate(decode($this->_getParam('id'))); // debugMessage($user->toArray()); #validate that the passwords aint the same if ($this->_getParam('oldpassword') == $this->_getParam('password')) { $session->setVar(SUCCESS_MESSAGE, "New Password should be the same as the current passowrd!"); $this->_redirect($this->view->baseUrl('profile/view/id/' . encode($user->getID()) . '/tab/account')); } # Change password try { $user->changePassword($this->_getParam('password')); $session->setVar(SUCCESS_MESSAGE, "Password successfully updated"); $this->_redirect($this->view->baseUrl('index/profileupdatesuccess')); } catch (Exception $e) { $session->setVar(ERROR_MESSAGE, "Error in changing Password. " . $e->getMessage()); } } }
/** * Set the worksheet title * * Checks the string for not allowed characters (:\/?*), * cuts it to maximum 31 characters and set the title. Damn * why are not-allowed chars nowhere to be found? Windows * help's no help... * * @access public * @param string $title Designed title */ public function setWorksheetTitle($title) { if (isEmptyString($title)) { $title = "Sheet 1"; } // strip out special chars first $title = preg_replace("/[\\\\|:|\\/|\\?|\\*|\\[|\\]]/", "", $title); // now cut it to the allowed length $title = substr($title, 0, 31); // set title $this->worksheet_title = $title; }
/** * Whether or not the object has an error * * @return boolean true if the object has an error, otherwise false */ function hasError() { return !isEmptyString($this->getErrorStackAsString()); }
function createAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $session = SessionWrapper::getInstance(); $this->_translate = Zend_Registry::get("translate"); $config = Zend_Registry::get("config"); $formvalues = $this->_getAllParams(); // debugMessage($formvalues); exit(); $isuserdoc = false; $iscompanydoc = false; if (!isArrayKeyAnEmptyString('userid', $formvalues)) { $isuserdoc = true; $folderid = $formvalues['userid']; } else { $iscompanydoc = true; $folderid = getCompanyID(); } if (isset($_FILES["FileInput"]) && $_FILES["FileInput"]["error"] == UPLOAD_ERR_OK && !array_key_exists('submit', $formvalues)) { if (!isset($_FILES['FileInput']['name'])) { $error = "<span class='alert alert-danger blocked'>Error: Please select a File to Upload.</span>"; $result = array('msg' => $error, 'result' => ''); echo $error; exit; } // if uploading a user document if ($isuserdoc) { // base path for user documents $destination_path = BASE_PATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . "users" . DIRECTORY_SEPARATOR . "user_"; // determine if user has destination avatar folder. Else user is editing there picture if (!is_dir($destination_path . $folderid)) { // no folder exits. Create the folder mkdir($destination_path . $folderid, 0775); } } // if uploading a company document if ($iscompanydoc) { // base path for user documents $destination_path = BASE_PATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . "company" . DIRECTORY_SEPARATOR . "comp_"; // determine if user has destination avatar folder. Else user is editing there picture if (!is_dir($destination_path . $folderid)) { // no folder exits. Create the folder mkdir($destination_path . $folderid, 0775); } } $destination_path = $destination_path . $folderid . DIRECTORY_SEPARATOR . "documents"; if (!is_dir($destination_path)) { mkdir($destination_path, 0775); } // create archive folder for each user $archivefolder = $destination_path . DIRECTORY_SEPARATOR . "archive"; if (!is_dir($archivefolder)) { mkdir($archivefolder, 0775); } $oldfile = $_FILES['FileInput']['name']; $File_Name = strtolower($oldfile); $File_Ext = findExtension($File_Name); //get file extention $ext = strtolower($_FILES['FileInput']['type']); // debugMessage($ext); $allowedformatsarray = explode(',', str_replace(' ', '', $config->uploads->docallowedformats)); // debugMessage($allowedformatsarray);exit(); $uploadedext = findExtension($File_Name); $currenttime = time(); //Random number to be added to name. $currenttime_file = $currenttime . '.' . $uploadedext; $thefilename = $destination_path . DIRECTORY_SEPARATOR . $currenttime_file; if (isEmptyString($folderid)) { $destination_path = BASE_PATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . "temp"; if (!is_dir($destination_path)) { // no folder exits. Create the folder mkdir($destination_path, 0775); } $thefilename = $destination_path . DIRECTORY_SEPARATOR . $currenttime_file; } // check if this is an ajax request if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { $error = "<span class='alert alert-danger blocked'>Error: No Request received.</span>"; $result = array('msg' => $error, 'result' => ''); echo $error; exit; } // debugMessage('size '.$_FILES["FileInput"]["size"]); // validate maximum allowed size $size = $_FILES["FileInput"]["size"]; if ($size > $config->uploads->docmaximumfilesize) { $error = "<span class='alert alert-danger blocked'>Error: Maximum allowed size exceeded.</span>"; $result = array('msg' => $error, 'result' => ''); echo $error; exit; } // validate allowed formats if (!in_array($File_Ext, $allowedformatsarray)) { $error = "<span class='alert alert-danger blocked'>Error: Format '." . $File_Ext . "' not supported. Formats allowed include '" . $config->uploads->docallowedformats . "'</span>"; $result = array('msg' => $error, 'result' => ''); echo $error; exit; } # move the file try { move_uploaded_file($_FILES['FileInput']['tmp_name'], $thefilename); // die('File '.$NewFileName.' Uploaded.'); $result = array('oldfilename' => $oldfile, 'newfilename' => $currenttime_file, 'msg' => 'Successfully uploaded', 'result' => 1, 'filesize' => $size); // debugMessage($result); echo json_encode($result); exit; } catch (Exception $e) { $error = 'Error in uploading File ' . $File_Name . '. ' . $e->getMessage(); $result = array('msg' => $error, 'result' => ''); echo $error; exit; } } if (array_key_exists('submit', $formvalues) || array_key_exists('id', $formvalues)) { $this->_setParam('uploadedbyid', $session->getVar('userid')); $this->_setParam('dateuploaded', DEFAULT_DATETIME); $this->_setParam("action", ACTION_CREATE); if (!isArrayKeyAnEmptyString('id', $formvalues)) { $this->_setParam("action", ACTION_EDIT); } // debugMessage($formvalues); exit(); parent::createAction(); } }
} return false; } </script> <body> <?php session_start(); require "class_lib_test.php"; // get op from session var $op = $_SESSION['username']; printToolbar($op, false); echo "</br>"; if (!isEmptyString($op)) { ?> <!--<form id="postMessage" action="postMessageHandler.php" enctype="multipart/form-data" method="POST">--> <form id = "postMessage" name="postMessage" method="POST" onsubmit="process(); return false;"> Enter a message (<?php echo $MAX_MESSAGE_LENGTH; ?> character limit):</br></br> <textarea onKeyPress="return taLimit(this)" onKeyUp="return taCount(this, 'counter')" id="message" name="message" value="msgVal" cols="60" rows="7"></textarea></br> <input type = "hidden" name = "toUser" value = "<?php echo $_GET['toUser']; ?> ">
/** * Clean out the data received from the screen by: * - remove empty/blank groupid - the groupid is not required and therefore is an empty value is maintained will cause an out of range exception * * @param Array $post_array */ function processPost($post_array) { $session = SessionWrapper::getInstance(); // check if the groupid is blank then remove it $permissions = $this->getPermissions(); $permissions_array = $permissions->toArray(); if (array_key_exists('permissions', $post_array)) { if (is_array($post_array['permissions'])) { $data = array(); foreach ($post_array['permissions'] as $key => $value) { $data[$key] = $value; if (array_key_exists('groupid', $value)) { if (isEmptyString($value['groupid'])) { unset($post_array['permissions'][$key]['groupid']); } } 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)) { unset($post_array['permissions'][$key]['id']); $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(); $data = $post_array['permissions'][$key]; unset($post_array['permissions'][$key]); $newkey = array_search_key_by_id($permissions_array, $value['id']); // debugMessage($data); $post_array['permissions'][$newkey] = $data; } } // end loop through permissions to unset empty groupids } } // now process the data // debugMessage($post_array['permissions']); // exit(); parent::processPost($post_array); }
function isRenderable($username) { return !isEmptyString($this->findByUsername($username)) ? true : false; }
function getCurrencyName() { $str = 'UGX'; if (!isEmptyString($this->getRateCurrency()) && $this->getRateCurrency() != 'UGX') { $str = $this->getRateCurrency(); } return $str; }
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(); }
/** * Send a notification to a user that a private message has been sent to them * * @return Bool whether the email notification has been sent * */ function sendInboxEmailNotification($fromemail, $fromname, $subject = '') { $template = new EmailTemplate(); # create mail object $mail = getMailInstance(); $sendername = $this->getSender()->getName(); if (!isEmptyString($fromname)) { $sendername = $fromname; } $senderemail = getEmailMessageSender(); if (!isEmptyString($fromemail)) { $senderemail = $fromemail; } // debugMessage($this->getRecipients()->toArray()); // the message reciever's first name $template->assign('firstname', $this->getRecipient()->getFirstName()); // the message sender's name $template->assign('emailsender', $sendername); $subject = $this->getSubject(); if (isEmptyString($this->getSubject())) { $subject = sprintf($this->translate->_('message_private_email_subject'), $sendername); } // message subject $mail->setSubject($subject); // message introduction $template->assign('emailintro', sprintf($this->translate->_('message_private_email_subject'), $sendername)); // message contents $template->assign('emailcontent', nl2br($this->getContents())); // the actual url will be built in the view $template->assign('emaillink', array("controller" => "message", "action" => "reply", "id" => encode($this->getID()))); // message html file $mail->setBodyHtml($template->render('messagenotification.phtml')); // debugMessage($template->render('messagenotification.phtml')); // add the recipient emails TODO if sent to many users, add all their emails $mail->addTo($this->getRecipient()->getEmail()); // $mail->addCc('*****@*****.**'); // set the send of the email address $mail->setFrom($senderemail, getAppName()); // send the message $mail->send(); $mail->clearRecipients(); $mail->clearSubject(); $mail->setBodyHtml(''); $mail->clearFrom(); return true; }
function getAttendanceDaysOfWeek() { $listarray = array(); $text = ''; $allvalues = getDaysOfWeek(); $thevalues = $this->getDaysOfWeekArray(); if (isEmptyString($this->getWorkingDays())) { return $text; } if (count($thevalues) > 0) { foreach ($thevalues as $value) { if (!isArrayKeyAnEmptyString($value, $allvalues)) { $listarray[] = $allvalues[$value]; } } } if (count($listarray) > 0) { $text = createHTMLCommaListFromArray($listarray, ', '); } return $text; }
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; }
public function testMltSearchReturnsFalseWithErrorsAvailableWhenSearchOperationIsNotSuccessful() { $es_mock = Mockery::mock('Elasticsearch\\Client'); $es_mock->shouldReceive('mlt')->once()->andReturn(['error' => 'error test', 'status' => 400]); $this->app->instance('Elasticsearch\\Client', $es_mock); $repo = $this->getRepo(); $response = $repo->mltSearch('test query', 100); $errors = $repo->errors(); assertThat($response, identicalTo(false)); assertThat($errors, not(isEmptyString())); }
function updateFromArray($table, $data, $id_field, $id_value, $fieldstoignore = array(), $datefields = array(), $password_field = array(), $foreignkeyfields = array()) { # check the table name if (trim($table) == "") { $this->setError("There is no table specified"); return false; } # no data if (count($data) == 0) { $this->setError("There is no data specified"); return false; } # no id field if (trim($id_field) == "") { $this->setError("There is no id field specified"); return false; } # no id field if (trim($id_value) == "") { $this->setError("There is no id value specified, cannot update all the rows in the table"); return false; } foreach ($data as $field => $value) { #check whether the field exists in the array of field to ignore. #If it does do not add it to the query fields if (!in_array($field, $fieldstoignore)) { #check whether the field is a date field, if it is do not #escape it using the mysql escape characters or quotation marks if (in_array($field, $datefields)) { $fields[] = sprintf("`%s` = %s", $field, changeDateFromPageToMySQLFormat($value)); } else { if (in_array($field, $password_field)) { $fields[] = sprintf("`%s` = %s", $field, "SHA('" . mysql_real_escape_string($value) . "')"); } else { if (in_array($field, $foreignkeyfields)) { // possible values that result into a null foreign key if (isEmptyString($value) or strval($value) == "0" or strtolower($value) == "null") { $fields[] = sprintf("`%s` = %s", $field, 'NULL'); } else { $fields[] = sprintf("`%s` = '%s'", $field, mysql_real_escape_string($value)); } } else { $fields[] = sprintf("`%s` = '%s'", $field, mysql_real_escape_string($value)); } } } } } $field_list = join(',', $fields); $query = sprintf("UPDATE `%s` SET %s WHERE `%s` = %s", $table, $field_list, $id_field, intval($id_value)); //echo "<br>Update query: <br>".$query."<br>";exit; $result = $this->CI->db->query($query); if (!$result) { # error occured $this->setError("An error occured while updating the database. Please try again later" . $this->CI->db->_error_message()); return false; } else { # return the number of rows updated return $result; } }
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; }
function getAttendanceTypes($value = '', $checkempty = false) { $array = array('0' => 'Employee does not submit timesheets', '1' => 'Employee submits timesheets and is paid hourly', '2' => 'Employee submits timesheets but is paid monthly'); if (!isEmptyString($value)) { if (!isArrayKeyAnEmptyString($value, $array)) { return $array[$value]; } else { return ''; } } if ($checkempty && isEmptyString($value)) { return ''; } return $array; }
function getFilePath($filename, $userid) { $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl(); $path = ''; if (hasAttachment($filename, $userid)) { $path = $baseUrl . '/uploads/users/user_' . $userid . '/benefits/' . $filename; } else { if (hasAttachment2($filename)) { $path = $baseUrl . '/uploads/temp/' . $filename; } if (!hasAttachment2($filename) && !isEmptyString($filename)) { // $path = $baseUrl.'/uploads/temp/'.$filename; } } return $path; }
/** * This function returns two results: * [triples: the generated triples, metaTriples: meta triples 2: the used templates] * * Unfortunately I haven't renamed the variables yet - result * is the array containing the result TRIPLES!! - its not this * 2 element. * */ private function myGenerate(BreadCrumb $breadCrumb, $value) { // result is the array containing: triples, meta triples, used templates $result = array(array(), array(), array()); $rootSubjectUri = RDFTriple::page($breadCrumb->getRoot()); // this array is only relevant on depth 0 $relatedClasses = array(); //$metaTriples = array(); //$usedTemplateNames = array(); // 'parent' means the parent of the value - thus subject and predicate $parentName = $this->breadCrumbTransformer->transform($breadCrumb); $parentResource = RDFTriple::page($parentName); $parentPropertyName = null; $tmp = $breadCrumb->peekTop(0); if (isset($tmp)) { $parentPropertyName = $tmp->getPropertyName(); } // Get all templates on this site, indexed by name // (there may be multiple templates with the same name) $nameToTemplates = SimpleWikiTemplateMatcher::match($value); //print_r($value); //print_r($nameToTemplates); //echo "NOW COMES THE STORM\n"; foreach ($nameToTemplates as $templateName => $templates) { if (strlen($templateName) < 1) { continue; } //echo "GOT TEMPLATE NAME $templateName\n"; $templateName = $this->mediaWikiUtil->toCanonicalWikiCase($templateName); if (!$this->templateNameFilter->doesAccept($templateName)) { continue; } $templateUri = RDFTriple::URI(DB_TEMPLATE_NS . $templateName, false); $result[2][$templateName] = 1; // Get annotations for the template - if there are any $lookupName = "Template:{$templateName}/doc"; if ($breadCrumb->getDepth() == 0) { $ta = $this->templateDb->getTemplateAnnotation($lookupName); // Create the triples for "relatesToClass" // But only for the page itself (not for sub templates) // if no related class exists, default to rdf:type owl:Thing if (isset($ta)) { foreach ($ta->getRelatedClasses() as $item) { $relatedClasses[$item] = 1; } } } foreach ($templates as $templateIndex => $template) { //echo "GOT TEMPLATE INDEX $templateIndex\n"; // Iterate over all arguments $arguments = $template->getArguments(); foreach ($arguments as $argumentName => $values) { //echo "GOT ARGUMENT NAME $argumentName\n"; // propertyNs defaults to DB_PROPERTY_NS unless there // exists a mapping in the templatedb. In that case it will // be set to DB_ONTOLOGY_NS $propertyNs = DB_PROPERTY_NS; $pa = null; if (isset($ta)) { $pas = $ta->getPropertyAnnotations(); if (array_key_exists($argumentName, $pas)) { $pa = $pas[$argumentName]; $propertyNs = DB_ONTOLOGY_NS; } } //print_r($ta); //echo "PROPERTY NS : $lookupName - $argumentName = $propertyNs\n"; // Fake a property mapping if there was none in the db // This maps argumentName back to iteself if (!isset($pa)) { // If there was no mapping we might ignore it // depending on an option (We can prevent this extractor // to generate triples with properties in the // dbp:property namespace // We allow such triples on subResources though. if ($this->allowUnmappedProperties != true && $breadCrumb->getDepth() == 0) { continue; } // If there was no mapping, also rename numeric // argument names (e.g. 1 becomes property1) // this is just cosmetic for the result if (is_numeric($argumentName)) { $argumentName = "property{$argumentName}"; } $pa = new PropertyAnnotation($argumentName); $pa->addMapping(new PropertyMapping($argumentName)); } foreach ($pa->getMappings() as $pm) { $parseHint = $pm->getParseHint(); //echo "Mapping $argumentName : {$pm->getRenamedValue()}\n\n"; // if the renamed value is not set, use the original // name // otherwise use the mapped value if (!isEmptyString($pm->getRenamedValue())) { $argumentName = $pm->getRenamedValue(); } $argumentName = trim($argumentName); //echo "Mapping $argumentName : {$pm->getRenamedValue()}\n\n"; // Skip empty properties // FIXME does that even happen? if (strlen($argumentName) < 1) { continue; } //echo "TN = $templateName, AN = $argumentName\n"; $childBreadcrumb = $breadCrumb->createClone(); $childBreadcrumb->push(new BreadcrumbNode($templateName, $templateIndex, $argumentName)); //$templateChildName = $this->breadcrumbToSubject($childBreadcrumb); $templateChildName = $this->breadCrumbTransformer->transform($childBreadcrumb); // If there is no parse hint we might be able to derive it if (!isset($parseHint)) { $parseHint = $this->deriveParseHintFromName($argumentName); } // Attempt to obtain a triple generator $tripleGenerator = $this->getTripleGenerator($parseHint); // If we DONT have a triple generator // we fall through to default handling $localResult = array(array(), array(), array()); if (isset($tripleGenerator)) { foreach ($values as $valueIndex => $value) { //echo "GOT VALUE $value\n"; $value = trim($value); // Skip empty values if ($value == "") { continue; } //echo "PROCESSING $templateChildName - $argumentName $value\n"; $tmp = $tripleGenerator->generate($templateChildName, $argumentName, $value); $localResult[0] = array_merge($localResult[0], $tmp); //echo "LOCALRESULT\n"; //print_r($localResult[0]); //print_r($triples); //echo "\nSigh\n"; //if(isset($triples)) // $result = array_merge($result, $triples); } // append the generated triples //continue; } else { // No parse hint - default handling // if property date and object an timespan // we extract it with following special case $argumentName = propertyToCamelCase($argumentName); $argumentName = encodeLocalName($argumentName); if (in_array($argumentName, $GLOBALS['W2RCFG']['ignoreProperties'])) { continue; } // turn the argument name into a property name $propertyName = $propertyNs . $argumentName; foreach ($values as $valueIndex => $value) { $value = trim($value); // Skip empty values if ($value == "") { continue; } if ($argumentName == "date") { $value = str_replace("[", "", $value); $value = str_replace("]", "", $value); $value = str_replace("–", "-", $value); } // Parse out sub templates // if something was extracted: // .) connect subject with subsubject // .) indicate usage at wikipage $subResources = $this->myGenerate($childBreadcrumb, $value); for ($i = 0; $i < 3; ++$i) { $localResult[$i] = array_merge($localResult[$i], $subResources[$i]); } //$result = array_merge($result, $triples); //echo "GOT OBJECT $value\n"; $localResult[0] = array_merge($localResult[0], parseAttributeValueWrapper($value, $templateChildName, $propertyName, $this->language)); //$result = array_merge($result, $triples); } } // For each triple add the ExtractedFromTemplate-Annotation // Exclude triples with wikiPageUsesTemplate as predicate though foreach ($localResult[0] as $triple) { $triple->addExtractedFromTemplateAnnotation($templateUri); } // Add on delete cascade annotation if ($breadCrumb->getDepth() > 1) { foreach ($localResult[0] as $triple) { $triple->addOnDeleteCascadeAnnotation($rootSubjectUri); } } // merge the results //for($i = 0; $i < 3; ++$i) // $result[$i] = array_merge($result[$i], $localResult[$i]); //} for ($i = 0; $i < 3; ++$i) { $result[$i] = array_merge($result[$i], $localResult[$i]); } } } /* How to connect a sub-subject to the root subject? if($breadCrumb->getDepth() == 0) continue; // Create the parent-child connection $parentChildTriple = new RDFtriple( $parentResource, RDFtriple::URI(DB_PROPERTY_NS . encodeLocalName($parentPropertyName), false), RDFtriple::page($templateChildName)); //$result[1][] = $parentChildTriple; */ } } if (count($relatedClasses) > 0) { foreach ($relatedClasses as $relatedClass => $dummy) { $result[1][] = new RDFtriple($parentResource, RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(DB_ONTOLOGY_NS . $relatedClass, false)); } } else { if ($breadCrumb->getDepth() == 0) { $result[1][] = new RDFtriple($parentResource, RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(OWL_THING, false)); } } // Add the wiki page uses template triples - but only on depth 0 if ($breadCrumb->getDepth() == 0) { foreach ($result[2] as $name => $dummy) { $result[1][] = new RDFTriple($parentResource, self::$wikiPageUsesTemplateUri, RDFTriple::URI(DB_TEMPLATE_NS . $name, false)); } } $n = count($result[0]) + count($result[1]); $this->log(TRACE, "Generated a total of {$n} triples at {$breadCrumb}"); foreach ($result[0] as $item) { $this->log(TRACE, $item); } foreach ($result[1] as $item) { $this->log(TRACE, $item); } return $result; }