public function onEntry() { global $cookie_found; if (isset($_POST['logTheUserOut'])) { unset(Session::sess()->user); header('Location: ' . BASEPATH . '/' . DEFAULTPAGE); exit; } elseif (isset($_POST['logTheUserIn']) && !empty($_POST['userName']) && !empty($_POST['userPass']) && !isset(Session::sess()->user)) { $userData = new Data_User(Data_User::LDAP, $_POST['userName'], $_POST['userPass']); Session::sess()->user = $userData->getUser(); } if (isset(Session::sess()->user)) { Acl::acl()->setRole(Session::sess()->user->role); } else { Acl::acl()->setRole(); } }
public function updateFromical(Data_User $user, $cache = TRUE) { if (!$user->hasCalendar()) { throw new Exception('User has no calendar information'); } $this->invitation = false; $this->user = $user; $this->userid = $user->userid; $this->username = $user->username; $this->email = $user->email; if (!empty($_REQUEST['comment'])) { $this->notes = $_REQUEST['comment']; } else { $this->notes = NULL; } #$this->updated = 'now'; $this->response = array('type' => 'ical', 'data' => NULL); $this->icalfill($cache); }
protected function getYibanInfo() { if (empty(self::$resource)) { return false; } if (!($db = Vera_Database::getInstance())) { return false; } $num = $this->getStuNum(); $result = $db->select('vera_Yiban', '*', array('xmu_num' => $num, 'fromApp' => 'mall')); if (!$result) { self::$yibanInfo = -1; return false; } self::$yibanInfo = $result[0]; return $result[0]; }
public static function getUsernameHTMLstatic($userid, $username, $hasprofile = FALSE, $includeToken = TRUE, $nolink = FALSE) { $userpage = '/user/' . $userid; if ($includeToken) { $userpage .= '?token=' . Data_User::getUserToken($userid, 'profile'); } $str = ''; if ($hasprofile && !$nolink) { $str .= '<a href="' . htmlspecialchars($userpage) . '"><img src="/res/user_grey.png" alt="User profile" />'; } $str .= htmlspecialchars($username); if ($hasprofile && !$nolink) { $str .= '</a>'; } if (isset($userid)) { $str = '<abbr title="' . htmlspecialchars($userid) . '">' . $str . '</abbr>'; } if (preg_match('|^@(.*)$|', $userid, $matches)) { $str .= ' (<a href="http://twitter.com/' . $matches[1] . '">' . $userid . '</a>)'; } return $str; }
public function acl(Data_User $user, $operation = 'write') { if ($user->isAdmin()) { return TRUE; } if ($user->userid === $this->owner) { return TRUE; } throw new Exception('Current user [' . $user->userid . '] do not have permissions to perform operation [' . $operation . '] on this Foodle.'); }
function __construct($resource) { parent::__construct($resource); }
public function saveUser(Data_User $user) { /* | userid | varchar(100) | NO | PRI | | | | username | tinytext | YES | | NULL | | | email | tinytext | YES | | NULL | | | org | tinytext | YES | | NULL | | | orgunit | tinytext | YES | | NULL | | | photol | text | YES | | NULL | | | photom | text | YES | | NULL | | | photos | text | YES | | NULL | | | notifications | text | YES | | NULL | | | features | text | YES | | NULL | | | calendar | text | YES | | NULL | | | timezone | tinytext | YES | | NULL | | | location | tinytext | YES | | NULL | | | realm | tinytext | YES | | NULL | | language userid, , username, email, org, orgunit, photol, photom, photos, notifications, features, calendar, timezone, location, realm, language */ if ($user->loadedFromDB) { // error_log('FoodleDB: Updating user data'); $sql = "\n\t\t\t\tUPDATE user SET " . self::sqlParameter('username', $user->username, 'null') . self::sqlParameter('email', $user->email, 'null') . self::sqlParameter('org', $user->org, 'null') . self::sqlParameter('orgunit', $user->orgunit, 'null') . self::sqlParameter('photol', $user->photol, 'null') . self::sqlParameter('photom', $user->photom, 'null') . self::sqlParameter('photos', $user->photos, 'null') . self::sqlParameter('notifications', Data_User::encode($user->notifications), 'null') . self::sqlParameter('features', Data_User::encode($user->features), 'null') . self::sqlParameter('calendar', Data_User::encode($user->getCalendar()), 'null') . self::sqlParameter('timezone', $user->timezone, 'null') . self::sqlParameter('location', $user->location, 'null') . self::sqlParameter('realm', $user->realm, 'realm') . self::sqlParameter('language', $user->language, 'null') . self::sqlParameter('auth', $user->auth, 'null') . self::sqlParameter('idp', $user->idp, 'null') . "\n\t\t\t\t\tupdated = NOW()\t\n\t\t\t\tWHERE userid = '" . $user->userid . "' \n\t\t\t"; } else { // error_log('FoodleDB: Adding a new user'); $sql = "\n\t\t\t\tINSERT INTO user (userid, username, email, org, orgunit, photol, photom, photos, notifications, features, calendar, timezone, location, realm, language, auth, idp) values (" . self::sqlParameter('userid', $user->userid, null, FALSE) . self::sqlParameter('username', $user->username, 'null', FALSE) . self::sqlParameter('email', $user->email, 'null', FALSE) . self::sqlParameter('org', $user->org, 'null', FALSE) . self::sqlParameter('orgunit', $user->orgunit, 'null', FALSE) . self::sqlParameter('photol', $user->photol, 'null', FALSE) . self::sqlParameter('photom', $user->photom, 'null', FALSE) . self::sqlParameter('photos', $user->photos, 'null', FALSE) . self::sqlParameter('notifications', Data_User::encode($user->notifications), 'null', FALSE) . self::sqlParameter('features', Data_User::encode($user->features), 'null', FALSE) . self::sqlParameter('calendar', Data_User::encode($user->getCalendar()), 'null', FALSE) . self::sqlParameter('timezone', $user->timezone, 'null', FALSE) . self::sqlParameter('location', $user->location, 'null', FALSE) . self::sqlParameter('realm', $user->realm, 'null', FALSE) . self::sqlParameter('language', $user->language, 'null', FALSE) . self::sqlParameter('auth', $user->auth, 'null', FALSE) . self::sqlParameter('idp', $user->idp, 'null', FALSE, FALSE) . ")\n\t\t\t"; } $this->execute($sql); }