use com\indigloo\Url; use com\indigloo\Configuration as Config; use com\indigloo\sc\auth\Login; use com\indigloo\ui\form\Message as FormMessage; use com\indigloo\ui\form\Sticky; use com\indigloo\Constants; use com\indigloo\sc\Constants as AppConstants; $gWeb = \com\indigloo\core\Web::getInstance(); $gSessionLogin = \com\indigloo\sc\auth\Login::getLoginInSession(); $loginId = $gSessionLogin->id; $loginName = $gSessionLogin->name; if (is_null($loginId)) { trigger_error("Error : NULL or invalid login_id", E_USER_ERROR); } $fUrl = Url::current(); $preferenceDao = new \com\indigloo\sc\dao\Preference(); $pData = $preferenceDao->get($loginId); $checked = array(); $checked["follow"] = $pData->follow ? "checked" : ""; $checked["comment"] = $pData->comment ? "checked" : ""; $checked["bookmark"] = $pData->bookmark ? "checked" : ""; ?> <!DOCTYPE html> <html> <head> <title> mail settings- <?php echo $loginName; ?>
function sendMail($row, $feed) { // determine if we want to send mail for this feed // #1 - who is the target for this mail? // the guy who is the "owner", e.g when I create a post // and you LIKE it, I should get a notification. // so "owner of entity" is the target of our mails. // if X created a post and Y liked it then X gets a mail // if Z likes the same post then also only X gets a mail // Y will not receive a mail. $verb = $row["verb"]; $ownerId = $row["owner_id"]; if ($verb == AppConstants::FOLLOW_VERB) { //mail target is the guy you are following $ownerId = $row["object_id"]; } // #2 : I am not interested in receiving mails where // I am the subject or doer of deed! if (!empty($ownerId) && $ownerId != $row["subject_id"]) { // #3 - get my preference for this feed $preferenceDao = new \com\indigloo\sc\dao\Preference(); $preferenceObj = $preferenceDao->get($ownerId); $flag = $this->getMailflag($preferenceObj, $verb); if ($flag) { $activityHtml = new \com\indigloo\sc\html\Activity(); $emailData = $activityHtml->getEmailData($feed); if (empty($emailData)) { $message = sprintf("ACTIVITY_ERROR : getting email data :id %d ", $row["id"]); throw new \Exception($message); } $text = $emailData["text"]; $html = $emailData["html"]; $userDao = new \com\indigloo\sc\dao\User(); $row = $userDao->getOnLoginId($ownerId); $name = $row["name"]; $email = $row["email"]; if (!empty($email)) { $code = WebMail::sendActivityMail($name, $email, $text, $html); if ($code > 0) { $message = sprintf("ACTIVITY_ERROR : sending mail : id %d ", $row["id"]); throw new \Exception($message); } } } //condition:mail_flag } //condition:owner }
// that also happens when user de-selects everything // for user selections - p array would contain only those // keys that user has selected. we have to map the rest of them // to false in preferences data. $parr = Util::tryArrayKey($fvalues, "p"); $pdata = array(); if (is_null($parr)) { //user has not selected any checckbox. $pdata = array("follow" => false, "comment" => false, "bookmark" => false); } else { // p array is not empty. // user has ticked some checkboxes. // set to false the keys that user has not selected. $pdata["follow"] = isset($parr["follow"]) ? true : false; $pdata["comment"] = isset($parr["comment"]) ? true : false; $pdata["bookmark"] = isset($parr["bookmark"]) ? true : false; } //save data for this loginId $pDataObj = json_encode($pdata); $preferenceDao = new \com\indigloo\sc\dao\Preference(); $preferenceDao->set($loginId, $pDataObj); $gWeb->store(Constants::FORM_MESSAGES, array("Your settings have been updated.")); //set success message header("Location: " . $fUrl); } catch (UIException $ex) { $gWeb->store(Constants::STICKY_MAP, $fvalues); $gWeb->store(Constants::FORM_ERRORS, $ex->getMessages()); header("Location: " . $fUrl); exit(1); } }