public function deleteAccount($userInfo, $userInfoSerializedHashed) { $registry = Zend_Registry::getInstance(); $people = Ml_Model_People::getInstance(); $share = Ml_Model_Share::getInstance(); $removeFiles = Ml_Model_RemoveFiles::getInstance(); $picture = Ml_Model_Picture::getInstance(); if (!is_array($userInfo) || !isset($userInfo['alias'])) { throw new Exception("Invalid userInfo data."); } //flag set to true when authorized to do so, least security resource if (!$registry->isRegistered("canDeleteAccount")) { throw new Exception("Not authorized to delete account."); } if (sha1(serialize($userInfo)) != $userInfoSerializedHashed) { throw new Exception("userInfo and serialized data doesn't match."); } $this->_dbAdapter->beginTransaction(); try { $picture->deleteFiles($userInfo); $removeFiles->addFilesGc($userInfo['id'], $userInfo['alias']); $this->_dbAdapter->query("INSERT INTO " . $this->_dbAdapter->quoteTableAs($this->_dbTable->getTableName()) . " SELECT id, alias, email, membershipdate, name, private_email, CURRENT_TIMESTAMP as delete_timestamp from people where " . $this->_dbAdapter->quoteInto("id = ?", $userInfo['id'])); $people->delete($userInfo['id']); $this->_dbAdapter->commit(); } catch (Exception $e) { $this->_dbAdapter->rollBack(); throw $e; } return true; }
public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
public function avatarProfile($person) { $registry = Zend_Registry::getInstance(); $config = $registry->get("config"); $picture = Ml_Model_Picture::getInstance(); $uid = $person['id']; $alias = $person['alias']; $name = $person['name']; $avatarInfo = $person['avatarInfo']; if (isset($avatarInfo)) { $picInfo = unserialize($avatarInfo); } $sizeInfo = $picture->getSizeInfo("small"); if (!$picInfo || empty($picInfo)) { return false; } else { $picUri = $config['services']['S3']['headshotsBucketAddress'] . $uid . '-' . $picInfo['secret'] . $sizeInfo['typeextension'] . '.jpg'; $dim = isset($picInfo['sizes'][$sizeInfo['urihelper']]['w']) && isset($picInfo['sizes'][$sizeInfo['urihelper']]['h']) ? ' width="' . $picInfo['sizes'][$sizeInfo['urihelper']]['w'] . '" height="' . $picInfo['sizes'][$sizeInfo['urihelper']]['h'] . '"' : ''; $html = '<a href="' . $config['services']['S3']['headshotsBucketAddress'] . $uid . '-' . $picInfo['secret'] . '-b.jpg' . '" title="' . $this->view->escape($name) . '\'s picture" class="new-window"><img src="' . $picUri . '"' . $dim . ' alt="' . $this->view->escape($alias) . "\" class=\"uid-" . $uid . "\" /></a>\n"; } return $html; }
public function pictureAction() { $registry = Zend_Registry::getInstance(); $request = $this->getRequest(); $signedUserInfo = $registry->get("signedUserInfo"); $picture = Ml_Model_Picture::getInstance(); $people = Ml_Model_People::getInstance(); $form = $picture->pictureForm(); if ($request->isPost() && $form->isValid($request->getPost())) { if ($form->getValue("delete")) { $change = $picture->deleteAvatar($signedUserInfo); } else { if ($form->Image->isUploaded()) { $fileInfo = $form->Image->getFileInfo(); $change = $picture->setAvatar($signedUserInfo, $fileInfo['Image']['tmp_name']); } } if (isset($change) && $change) { //refresh $signedUserInfo = $people->getById($signedUserInfo['id']); $registry->set("signedUserInfo", $signedUserInfo); } $form->getValues(); } $this->view->submitPictureForm = $form; }
public function avatar($person, $size = "small", $link = true, $dimension = array("width" => false, "height" => false)) { $registry = Zend_Registry::getInstance(); $config = $registry->get("config"); $picture = Ml_Model_Picture::getInstance(); $router = Zend_Controller_Front::getInstance()->getRouter(); if (isset($person['people_deleted.id']) && !empty($person['people_deleted.id'])) { $uid = $person['people_deleted.id']; $name = $person['people_deleted.name']; } else { if (isset($person['people.id'])) { $uid = $person['people.id']; $alias = $person['people.alias']; $name = $person['people.name']; $avatarInfo = $person['people.avatarInfo']; } else { $uid = $person['id']; $alias = $person['alias']; $name = $person['name']; $avatarInfo = $person['avatarInfo']; } } if (isset($avatarInfo)) { $picInfo = unserialize($avatarInfo); } $sizeInfo = $picture->getSizeInfo($size); if (!isset($alias)) { //$html = '<img src="' . //$config['cdn'] . //'images/noavatar' . //$sizeInfo['typeextension'].'.gif" width="'.$sizeInfo['dimension'] . //'" height="'.$sizeInfo['dimension'].'" class="uid-' . //$uid.'" alt="" />'; $html = ''; } else { if (!$picInfo || empty($picInfo)) { if ($sizeInfo['name'] == "square") { $height = $sizeInfo['dimension']; } else { $height = round($sizeInfo['dimension'] * 2 / 3); } if ($dimension['height']) { $height = $dimension['height']; } if ($dimension['width']) { $width = $dimension['width']; } else { $width = $sizeInfo['dimension']; } $html = ""; if ($link) { $html .= '<a href="' . $router->assemble(array("username" => $alias), "filestream_1stpage") . '/">'; } $html .= '<img src="' . $config['cdn'] . 'images/happy-face' . $sizeInfo['typeextension'] . '.png" width="' . $this->view->escape($width) . '" height="' . $this->view->escape($height) . '" alt="(' . $this->view->escape($alias) . ' has no picture)"' . " class=\"uid-" . $uid . "\" />"; if ($link) { $html .= "</a>\n"; } } else { $picUri = $config['services']['S3']['headshotsBucketAddress'] . $uid . '-' . $picInfo['secret'] . $sizeInfo['typeextension'] . '.jpg'; if (isset($picInfo['sizes'][$sizeInfo['urihelper']]['w']) && isset($picInfo['sizes'][$sizeInfo['urihelper']]['h'])) { if (isset($dimension['width'])) { $width = $dimension['width']; } else { $width = $picInfo['sizes'][$sizeInfo['urihelper']]['w']; } if (isset($dimension['height'])) { $height = $dimension['height']; } else { $height = $picInfo['sizes'][$sizeInfo['urihelper']]['h']; } $dim = ' width="' . $width . '" height="' . $height . '"'; } else { $dim = ''; } $html = ""; if ($link) { $html .= '<a href="' . $this->view->url(array("username" => $alias), "filestream_1stpage") . '" title="' . $this->view->escape($name) . '">'; } $html .= '<img src="' . $picUri . '"' . $dim . ' alt="' . $this->view->escape($alias) . "\" class=\"uid-" . $uid . "\" />"; if ($link) { $html .= "</a>\n"; } } } return $html; }