本文整理汇总了PHP中ca_users类的典型用法代码示例。如果您正苦于以下问题:PHP ca_users类的具体用法?PHP ca_users怎么用?PHP ca_users使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ca_users类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Index
public function Index()
{
#
# User-generated comments, tags and ratings
#
$t_siteComments = new SiteComments();
$va_user_comments = $t_siteComments->getComments(null, true);
$va_comments = array();
if (is_array($va_user_comments)) {
foreach ($va_user_comments as $va_user_comment) {
$va_comment = array();
if ($va_user_comment["comment"]) {
$va_comment["comment"] = $va_user_comment["comment"];
# TODO: format date based on locale
$va_comment["date"] = date("n/j/Y", $va_user_comment["created_on"]);
$va_comment["created_on"] = $va_user_comment["created_on"];
# -- get name of commenter
$t_user = new ca_users($va_user_comment["user_id"]);
$va_comment["author"] = $t_user->getName();
$va_comment["email"] = $va_user_comment["email"];
$va_comment["name"] = $va_user_comment["name"];
$va_comments[] = $va_comment;
}
}
}
$this->view->setVar('comments', $va_comments);
$this->render('Comments/comments_html.php');
}
示例2: renderWidget
public function renderWidget($ps_widget_id, &$pa_settings)
{
parent::renderWidget($ps_widget_id, $pa_settings);
$vn_threshold = time() - $pa_settings['logins_since'] * 60 * 60;
$o_db = new Db();
$qr_res = $o_db->query("\n\t\t\t\tSELECT e.code, e.message, e.date_time\n\t\t\t\tFROM ca_eventlog e\n\t\t\t\tWHERE\n\t\t\t\t\t(e.date_time >= ?) AND (e.code = 'LOGN')\n\t\t\t\tORDER BY\n\t\t\t\t\te.date_time DESC\n\t\t\t", $vn_threshold);
$va_login_list = array();
$t_user = new ca_users();
$va_user_cache = array();
while ($qr_res->nextRow()) {
$va_log = $qr_res->getRow();
$vs_message = $va_log['message'];
$va_tmp = explode(';', $vs_message);
$vs_username = '?';
if (preg_match('!\'([^\']+)\'!', $va_tmp[0], $va_matches)) {
$vs_username = $va_matches[1];
}
$va_log['username'] = $vs_username;
if (!isset($va_user_cache[$vs_username])) {
if ($t_user->load(array('user_name' => $vs_username))) {
$va_user_cache[$vs_username] = array('fname' => $t_user->get('fname'), 'lname' => $t_user->get('lname'), 'email' => $t_user->get('email'));
} else {
$va_user_cache[$vs_username] = array('fname' => '?', 'lname' => '?', 'email' => '?');
}
}
$va_log = array_merge($va_log, $va_user_cache[$vs_username]);
$va_log['ip'] = str_replace('IP=', '', $va_tmp[1]);
$va_login_list[] = $va_log;
}
$this->opo_view->setVar('request', $this->getRequest());
$this->opo_view->setVar('login_list', $va_login_list);
return $this->opo_view->render('main_html.php');
}
示例3: authenticate
public static function authenticate($ps_username, $ps_password = '', $pa_options = null)
{
$t_user = new ca_users();
$t_user->load($ps_username);
if ($t_user->getPrimaryKey() > 0) {
$vs_hash = $t_user->get('password');
if (preg_match('/^[a-f0-9]{32}$/', $vs_hash)) {
// old-style md5 passwords
//throw new CaUsersException(_t('The stored password for this user seems to be in legacy format. Please update the user account by resetting the password.'));
if (md5($ps_password) == $vs_hash) {
// if the md5 hash matches, authenticate successfully and move the user over to pbkdf2 key
$t_user->setMode(ACCESS_WRITE);
// ca_users::update takes care of the hashing by calling AuthenticationManager::updatePassword()
$t_user->set('password', $ps_password);
$t_user->update();
return true;
} else {
return false;
}
}
return validate_password($ps_password, $vs_hash);
} else {
return false;
}
}
示例4: testBooleanOperators
public function testBooleanOperators()
{
$vo_acr = AccessRestrictions::load(true);
// OR
$va_access_restrictions = array("administrate/setup/list_editor/ListEditorController" => array("default" => array("operator" => "OR", "actions" => array("can_edit_ca_lists", "can_create_ca_lists", "can_delete_ca_lists"))));
$vo_acr->opa_acr = $va_access_restrictions;
// no role -> can't access controller
$this->opt_role->setMode(ACCESS_WRITE);
$this->opt_role->setRoleActions(array());
$this->opt_role->update();
ca_users::$s_user_action_access_cache = array();
$vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
$this->assertFalse($vb_access);
// has one of the OR-ed roles -> can access controller
$this->opt_role->setMode(ACCESS_WRITE);
$va_actions = $va_access_restrictions["administrate/setup/list_editor/ListEditorController"]["default"]["actions"];
$this->opt_role->setRoleActions(array($va_actions[array_rand($va_actions)]));
$this->opt_role->update();
ca_users::$s_user_action_access_cache = array();
$vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
$this->assertTrue($vb_access);
// AND
$va_access_restrictions = array("administrate/setup/list_editor/ListEditorController" => array("default" => array("operator" => "AND", "actions" => array("can_edit_ca_lists", "can_create_ca_lists", "can_delete_ca_lists"))));
$vo_acr->opa_acr = $va_access_restrictions;
// no role -> can't access controller
$this->opt_role->setMode(ACCESS_WRITE);
$this->opt_role->setRoleActions(array());
$this->opt_role->update();
ca_users::$s_user_action_access_cache = array();
$vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
$this->assertFalse($vb_access);
// has one of the AND-ed roles -> can't access controller
$this->opt_role->setMode(ACCESS_WRITE);
$va_actions = $va_access_restrictions["administrate/setup/list_editor/ListEditorController"]["default"]["actions"];
$this->opt_role->setRoleActions(array($va_actions[array_rand($va_actions)]));
$this->opt_role->update();
ca_users::$s_user_action_access_cache = array();
$vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
$this->assertFalse($vb_access);
// has all AND-ed roles -> can access controller
$this->opt_role->setMode(ACCESS_WRITE);
$this->opt_role->setRoleActions($va_actions);
$this->opt_role->update();
ca_users::$s_user_action_access_cache = array();
$vb_access = $vo_acr->userCanAccess($this->opt_user->getPrimaryKey(), array("administrate", "setup", "list_editor"), "ListEditor", "Edit");
$this->assertTrue($vb_access);
}
示例5: send
/**
*
*/
public static function send($pn_user_id, $ps_message)
{
global $AUTH_CURRENT_USER_ID, $g_request;
if (!function_exists("curl_init")) {
return false;
}
if ($pn_user_id == $AUTH_CURRENT_USER_ID) {
$t_user = $g_request->user;
// use request user object
} else {
$t_user = new ca_users($pn_user_id);
}
if (!$t_user->getPrimaryKey()) {
return null;
}
if (!$t_user->get('sms_number')) {
return null;
}
if (!($vn_sendhub_contact_id = $t_user->getVar('sms_sendhub_contact_id')) || $t_user->getVar('sms_sendhub_phone_number') != $t_user->get('sms_number')) {
if (!($vn_sendhub_contact_id = WLPlugSMSSendHub::addContact($t_user))) {
// TODO: check and log errors here
return null;
}
}
$vs_user = $t_user->getAppConfig()->get('sms_user');
$vs_api_key = $t_user->getAppConfig()->get('sms_api_key');
$vs_url = "https://api.sendhub.com/v1/messages/?username={$vs_user}&api_key={$vs_api_key}";
$o_ch = curl_init();
$ps_message = stripslashes(rawurldecode($ps_message));
$ps_message = trim(preg_replace("!\n+!", "\\" . "n", $ps_message));
curl_setopt($o_ch, CURLOPT_URL, $vs_url);
curl_setopt($o_ch, CURLOPT_HEADER, false);
curl_setopt($o_ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt($o_ch, CURLOPT_POSTFIELDS, '{"contacts":[' . $vn_sendhub_contact_id . '],"text":"' . $ps_message . '"}');
curl_setopt($o_ch, CURLOPT_RETURNTRANSFER, 1);
$vs_return = curl_exec($o_ch);
$va_return = json_decode($vs_return);
// TODO: check and log errors here
curl_close($o_ch);
return true;
}
示例6: caClientServicesGetSenderName
/**
*
*
* @param array $pa_data
* @param array $pa_options
*
* @return string
*/
function caClientServicesGetSenderName($pa_data, $pa_options = null)
{
global $g_caClientServicesNameCache;
if (!isset($g_caClientServicesNameCache[$pa_data['from_user_id']])) {
$t_user = new ca_users($pa_data['from_user_id']);
return $g_caClientServicesNameCache[$pa_data['from_user_id']] = $t_user->get('fname') . ' ' . $t_user->get('lname');
} else {
return $g_caClientServicesNameCache[$pa_data['from_user_id']];
}
}
示例7: Show
//.........这里部分代码省略.........
// not configured for browse
$this->request->session->setVar($this->ops_tablename . '_' . $this->ops_appname . '_detail_current_browse_id', null);
$this->view->setVar('show_browse', false);
}
}
$this->request->session->setVar($this->ops_tablename . '_' . $this->ops_appname . '_detail_current_item_id', $vn_item_id);
# Next and previous navigation
$opo_result_context = new ResultContext($this->request, $this->ops_tablename, ResultContext::getLastFind($this->request, $this->ops_tablename));
$this->view->setVar('next_id', $opo_result_context->getNextID($vn_item_id));
$this->view->setVar('previous_id', $opo_result_context->getPreviousID($vn_item_id));
# Is the item we're show details for in the result set?
$this->view->setVar('is_in_result_list', $opo_result_context->getIndexInResultList($vn_item_id) != '?');
# Item instance and id
$this->view->setVar('t_item', $t_item);
$this->view->setVar($t_item->getPrimaryKey(), $vn_item_id);
# Item - preferred
$this->view->setVar('label', $t_item->getLabelForDisplay());
# Item - nonpreferred
$this->view->setVar('nonpreferred_labels', caExtractValuesByUserLocale($t_item->getNonPreferredLabels()));
# Item timestamps (creation and last change)
if ($va_entry_info = $t_item->getCreationTimestamp()) {
$this->view->setVar('date_of_entry', date('m/d/Y', $va_entry_info['timestamp']));
}
if ($va_last_change_info = $t_item->getLastChangeTimestamp()) {
$this->view->setVar('date_of_last_change', date('m/d/Y', $va_last_change_info['timestamp']));
}
# Media representations to display (objects only)
if (method_exists($t_item, 'getPrimaryRepresentationInstance')) {
if ($t_primary_rep = $t_item->getPrimaryRepresentationInstance()) {
if (!sizeof($va_access_values) || in_array($t_primary_rep->get('access'), $va_access_values)) {
// check rep access
$this->view->setVar('t_primary_rep', $t_primary_rep);
$va_rep_display_info = caGetMediaDisplayInfo('detail', $t_primary_rep->getMediaInfo('media', 'INPUT', 'MIMETYPE'));
$this->view->setVar('primary_rep_display_version', $va_rep_display_info['display_version']);
unset($va_display_info['display_version']);
$va_rep_display_info['poster_frame_url'] = $t_primary_rep->getMediaUrl('media', $va_rep_display_info['poster_frame_version']);
unset($va_display_info['poster_frame_version']);
$this->view->setVar('primary_rep_display_options', $va_rep_display_info);
}
}
}
#
# User-generated comments, tags and ratings
#
$va_user_comments = $t_item->getComments(null, true);
$va_comments = array();
if (is_array($va_user_comments)) {
foreach ($va_user_comments as $va_user_comment) {
if ($va_user_comment["comment"] || $va_user_comment["media1"] || $va_user_comment["media2"] || $va_user_comment["media3"] || $va_user_comment["media4"]) {
# TODO: format date based on locale
$va_user_comment["date"] = date("n/j/Y", $va_user_comment["created_on"]);
# -- get name of commenter
$t_user = new ca_users($va_user_comment["user_id"]);
$va_user_comment["author"] = $t_user->getName();
$va_comments[] = $va_user_comment;
}
}
}
$this->view->setVar('comments', $va_comments);
$va_user_tags = $t_item->getTags(null, true);
$va_tags = array();
if (is_array($va_user_tags)) {
foreach ($va_user_tags as $va_user_tag) {
if (!in_array($va_user_tag["tag"], $va_tags)) {
$va_tags[] = $va_user_tag["tag"];
}
}
}
$this->view->setVar('tags_array', $va_tags);
$this->view->setVar('tags', implode(", ", $va_tags));
$this->view->setVar('result_context', $opo_result_context);
# -- get average user ranking
$this->view->setVar('ranking', $t_item->getAverageRating(null));
// null makes it ignore moderation status
# -- get number of user rankings
$this->view->setVar('numRankings', $t_item->getNumRatings(null));
// null makes it ignore moderation status
#
# Miscellaneous useful information
#
$this->view->setVar('t_relationship_types', new ca_relationship_types());
// relationship types object - used for displaying relationship type of related authority information
if (method_exists($t_item, 'getTypeName')) {
$this->view->setVar('typename', $t_item->getTypeName());
}
// Record view
$t_item->registerItemView($this->request->getUserID());
//
// Render view
//
if (isset($pa_options['view']) && $pa_options['view']) {
$this->render($pa_options['view']);
} else {
if ($this->getView()->viewExists($this->ops_tablename . '_' . $t_item->getTypeCode() . '_detail_html.php')) {
$this->render($this->ops_tablename . '_' . $t_item->getTypeCode() . '_detail_html.php');
} else {
$this->render($this->ops_tablename . '_detail_html.php');
}
}
}
示例8: exists
/**
* Check if a user name exists
*
* @param mixed $ps_user_name_or_id The user name or numeric user_id of the user
* @return boolean True if user exists, false if not
*/
public function exists($ps_user_name_or_id)
{
$t_user = new ca_users();
if ($t_user->load($ps_user_name_or_id)) {
return true;
} else {
if ($t_user->load(array("user_name" => $ps_user_name_or_id))) {
return true;
}
}
return false;
}
示例9: getRoleList
/**
* Get list of all roles supported by the application. If you want to get the current user's roles, use getUserRoles()
*
* @return array Returns associative array of roles. Key is role id, value is array containing information about the role.
*
* The role information array contains the following keys:
* role_id (numeric id you can use in addRoles(), deleteRoles(), hasRole(), etc.)
* name (the full name of the role)
* code (a short code used for the role)
* description (narrative description of role)
*/
public function getRoleList()
{
$t_user = new ca_users();
return $t_user->getRoleList();
}
示例10: checkACLAccessForUser
/**
* Checks access control list for currently loaded row for the specified user and returns an access value. Values are:
*
* __CA_ACL_NO_ACCESS__ (0)
* __CA_ACL_READONLY_ACCESS__ (1)
* __CA_ACL_EDIT_ACCESS__ (2)
* __CA_ACL_EDIT_DELETE_ACCESS__ (3)
*
* @param ca_users $t_user A ca_users object
* @param int $pn_id Optional row_id to check ACL for; if omitted currently loaded row_id is used
* @return int An access value
*/
public function checkACLAccessForUser($t_user, $pn_id = null)
{
if (!$this->supportsACL()) {
return __CA_ACL_EDIT_DELETE_ACCESS__;
}
if (!$pn_id) {
$pn_id = (int) $this->getPrimaryKey();
if (!$pn_id) {
return null;
}
}
if ($t_user->canDoAction('is_administrator')) {
return __CA_ACL_EDIT_DELETE_ACCESS__;
}
require_once __CA_MODELS_DIR__ . '/ca_acl.php';
return ca_acl::accessForRow($t_user, $this->tableNum(), $pn_id);
}
示例11: filterHitsByACL
/**
* @param $pa_hits Array of row_ids to filter. *MUST HAVE row_ids AS KEYS, NOT VALUES*
*/
public function filterHitsByACL($pa_hits, $pn_user_id, $pn_access = __CA_ACL_READONLY_ACCESS__, $pa_options = null)
{
if (!sizeof($pa_hits)) {
return $pa_hits;
}
if (!(int) $pn_user_id) {
$pn_user_id = 0;
}
if (!($t_table = $this->opo_datamodel->getInstanceByTableNum($this->opn_tablenum, true))) {
return $pa_hits;
}
$vs_search_tmp_table = $this->loadListIntoTemporaryResultTable($pa_hits, md5(isset($pa_options['search']) ? $pa_options['search'] : rand(0, 1000000)));
$vs_table_name = $t_table->tableName();
$vs_table_pk = $t_table->primaryKey();
$t_user = new ca_users($pn_user_id);
if (is_array($va_groups = $t_user->getUserGroups()) && sizeof($va_groups)) {
$va_group_ids = array_keys($va_groups);
$vs_group_sql = '
OR
(ca_acl.group_id IN (?))';
$va_params = array((int) $this->opn_tablenum, (int) $pn_user_id, $va_group_ids, (int) $pn_access);
} else {
$va_group_ids = null;
$vs_group_sql = '';
$va_params = array((int) $this->opn_tablenum, (int) $pn_user_id, (int) $pn_access);
}
$va_hits = array();
if ($pn_access <= $this->opo_app_config->get('default_item_access_level')) {
// Requested access is more restrictive than default access (so return items with default ACL)
// Find records that have ACL that matches
$qr_sort = $this->opo_db->query("\n\t\t\t\t\tSELECT ca_acl.row_id\n\t\t\t\t\tFROM ca_acl\n\t\t\t\t\tINNER JOIN {$vs_search_tmp_table} ON {$vs_search_tmp_table}.row_id = ca_acl.row_id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(ca_acl.table_num = ?)\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(ca_acl.user_id = ?)\n\t\t\t\t\t\t\t{$vs_group_sql}\n\t\t\t\t\t\t\tOR \n\t\t\t\t\t\t\t(ca_acl.user_id IS NULL AND ca_acl.group_id IS NULL)\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t(ca_acl.access >= ?)\n\t\t\t\t", $va_params);
while ($qr_sort->nextRow()) {
$va_row = $qr_sort->getRow();
$va_hits[$va_row['row_id']] = true;
}
// Find records with default ACL
$qr_sort = $this->opo_db->query("\n\t\t\t\t\tSELECT {$vs_search_tmp_table}.row_id\n\t\t\t\t\tFROM {$vs_search_tmp_table}\n\t\t\t\t\tLEFT OUTER JOIN ca_acl ON {$vs_search_tmp_table}.row_id = ca_acl.row_id AND ca_acl.table_num = ?\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tca_acl.row_id IS NULL;\n\t\t\t\t", array((int) $this->opn_tablenum));
while ($qr_sort->nextRow()) {
$va_row = $qr_sort->getRow();
$va_hits[$va_row['row_id']] = true;
}
} else {
// Default access is more restrictive than requested access (so *don't* return items with default ACL)
// Find records that have ACL that matches
$qr_sort = $this->opo_db->query("\n\t\t\t\t\tSELECT ca_acl.row_id\n\t\t\t\t\tFROM ca_acl\n\t\t\t\t\tINNER JOIN {$vs_search_tmp_table} ON {$vs_search_tmp_table}.row_id = ca_acl.row_id\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t(ca_acl.table_num = ?)\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(ca_acl.user_id = ?)\n\t\t\t\t\t\t\t{$vs_group_sql}\n\t\t\t\t\t\t\tOR \n\t\t\t\t\t\t\t(ca_acl.user_id IS NULL AND ca_acl.group_id IS NULL)\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND\n\t\t\t\t\t\t(ca_acl.access >= ?)\n\t\t\t\t", $va_params);
while ($qr_sort->nextRow()) {
$va_row = $qr_sort->getRow();
$va_hits[$va_row['row_id']] = true;
}
}
$this->cleanupTemporaryResultTable();
return $va_hits;
}
示例12: GetUserProfileInfo
/**
* Return user profile values for specified user
*/
public function GetUserProfileInfo()
{
if (!$this->request->user->canDoAction('can_manage_clients')) {
return null;
}
$pn_user_id = $this->request->getParameter('user_id', pInteger);
$t_user = new ca_users($pn_user_id);
$va_profile_prefs = $t_user->getValidPreferences('profile');
if (is_array($va_profile_prefs) && sizeof($va_profile_prefs)) {
$va_elements = array();
foreach ($va_profile_prefs as $vs_pref) {
$va_pref_info = $t_user->getPreferenceInfo($vs_pref);
$va_elements[str_replace('user_profile_', '', $vs_pref)] = array($t_user->getPreference($vs_pref));
}
$this->view->setVar("profile_values", $va_elements);
}
$this->view->setVar("user_id", $pn_user_id);
$this->render('ajax_user_profile_info_json.php');
}
示例13: resetSave
function resetSave()
{
MetaTagManager::setWindowTitle($this->request->config->get("app_display_name") . ": " . _t("Reset Password"));
$ps_action = $this->request->getParameter('action', pString);
if (!$ps_action) {
$ps_action = "reset";
}
$ps_key = $this->request->getParameter('key', pString);
$ps_key = preg_replace("/[^A-Za-z0-9]+/", "", $ps_key);
$this->view->setVar("key", $ps_key);
$this->view->setVar("email", $this->request->config->get("ca_admin_email"));
$o_check_key = new Db();
$qr_check_key = $o_check_key->query("\n\t\t\t\tSELECT user_id \n\t\t\t\tFROM ca_users \n\t\t\t\tWHERE\n\t\t\t\t\tmd5(concat(concat(user_id, '/'), password)) = ?\n\t\t\t", $ps_key);
#
# Check reset key
#
if (!$qr_check_key->nextRow() || !($vs_user_id = $qr_check_key->get("user_id"))) {
$this->view->setVar("action", "reset_failure");
$this->view->setVar("message", _t("Your password could not be reset"));
$this->render('LoginReg/form_reset_html.php');
} else {
$ps_password = $this->request->getParameter('password', pString);
$ps_password_confirm = $this->request->getParameter('password_confirm', pString);
switch ($ps_action) {
case 'reset_save':
if (!$ps_password || !$ps_password_confirm) {
$this->view->setVar("message", _t("Please enter and re-type your password."));
$ps_action = "reset";
break;
}
if ($ps_password != $ps_password_confirm) {
$this->view->setVar("message", _t("Passwords do not match. Please try again."));
$ps_action = "reset";
break;
}
$t_user = new ca_users();
$t_user->purify(true);
$t_user->load($vs_user_id);
# verify user exists with this e-mail address
if ($t_user->getPrimaryKey()) {
# user with e-mail already exists...
$t_user->setMode(ACCESS_WRITE);
$t_user->set("password", $ps_password);
$t_user->update();
if ($t_user->numErrors()) {
$this->notification->addNotification(join("; ", $t_user->getErrors()), __NOTIFICATION_TYPE_INFO__);
$ps_action = "reset_failure";
} else {
$ps_action = "reset_success";
$o_view = new View($this->request, array($this->request->getViewsDirectoryPath()));
# -- generate email subject
$vs_subject_line = $o_view->render("mailTemplates/notification_subject.tpl");
# -- generate mail text from template - get both the html and text versions
$vs_mail_message_text = $o_view->render("mailTemplates/notification.tpl");
$vs_mail_message_html = $o_view->render("mailTemplates/notification_html.tpl");
caSendmail($t_user->get('email'), $this->request->config->get("ca_admin_email"), $vs_subject_line, $vs_mail_message_text, $vs_mail_message_html);
}
break;
} else {
$this->notification->addNotification(_t("Invalid user"), __NOTIFICATION_TYPE_INFO__);
$ps_action = "reset_failure";
}
}
$this->view->setVar("action", $ps_action);
$this->render('LoginReg/form_reset_html.php');
}
}
示例14: getSetsForUser
public function getSetsForUser($pa_options)
{
if (!is_array($pa_options)) {
$pa_options = array();
}
$pn_user_id = isset($pa_options['user_id']) ? (int) $pa_options['user_id'] : null;
$pm_table_name_or_num = isset($pa_options['table']) ? $pa_options['table'] : null;
if ($pm_table_name_or_num && !($vn_table_num = $this->_getTableNum($pm_table_name_or_num))) {
return null;
}
$pm_type = isset($pa_options['setType']) ? $pa_options['setType'] : null;
$pn_access = isset($pa_options['access']) ? $pa_options['access'] : null;
$pa_public_access = isset($pa_options['checkAccess']) ? $pa_options['checkAccess'] : null;
if ($pa_public_access && is_numeric($pa_public_access) && !is_array($pa_public_access)) {
$pa_public_access = array($pa_public_access);
}
for ($vn_i = 0; $vn_i < sizeof($pa_public_access); $vn_i++) {
$pa_public_access[$vn_i] = intval($pa_public_access[$vn_i]);
}
if ($pn_user_id) {
$va_extra_joins = array();
$va_sql_wheres = array("(cs.deleted = 0)");
$va_sql_params = array();
$o_db = $this->getDb();
if ($vn_table_num) {
$va_sql_wheres[] = "(cs.table_num = ?)";
$va_sql_params[] = (int) $vn_table_num;
}
if (!is_null($pa_public_access) && is_array($pa_public_access) && sizeof($pa_public_access)) {
$va_sql_wheres[] = "(cs.access IN (?))";
$va_sql_params[] = $pa_public_access;
}
if (isset($pm_type) && $pm_type) {
if (is_numeric($pm_type)) {
$va_sql_wheres[] = "(cs.type_id = ?)";
$va_sql_params[] = (int) $pm_type;
} else {
# --- look up code of set type
$t_list = new ca_lists();
$vn_type_id = $t_list->getItemIDFromList("set_types", $pm_type);
if ($vn_type_id) {
$va_sql_wheres[] = "(cs.type_id = ?)";
$va_sql_params[] = (int) $vn_type_id;
}
}
}
if ($pa_options["owner"]) {
$va_sql_wheres[] = "(cs.user_id = " . $pn_user_id . ")";
} else {
# --- if owner is not set to true, we're finding all sets the user has access to or is owner of
# --- we also check the users' access to the set if set
$t_user = new ca_users();
$t_user->load($pn_user_id);
if ($t_user->getPrimaryKey()) {
$vs_access_sql = $pn_access > 0 ? " AND (access >= " . intval($pn_access) . ")" : "";
if (is_array($va_groups = $t_user->getUserGroups()) && sizeof($va_groups)) {
$vs_sql = "(\n\t\t\t\t\t\t\t(cs.user_id = " . intval($pn_user_id) . ") OR \n\t\t\t\t\t\t\t(cs.set_id IN (\n\t\t\t\t\t\t\t\t\tSELECT set_id \n\t\t\t\t\t\t\t\t\tFROM ca_sets_x_user_groups \n\t\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t\tgroup_id IN (" . join(',', array_keys($va_groups)) . ") {$vs_access_sql}\n\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t (sdatetime IS NULL AND edatetime IS NULL)\n\t\t\t\t\t\t\t\t\t\t\t OR \n\t\t\t\t\t\t\t\t\t\t\t (\n\t\t\t\t\t\t\t\t\t\t\t\tsdatetime <= " . time() . " AND edatetime >= " . time() . "\n\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)";
} else {
$vs_sql = "(cs.user_id = {$pn_user_id})";
}
$vs_sql .= " OR (cs.set_id IN (\n\t\t\t\t\t\t\t\t\t\t\tSELECT set_id \n\t\t\t\t\t\t\t\t\t\t\tFROM ca_sets_x_users \n\t\t\t\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t\t\t\tuser_id = {$pn_user_id} {$vs_access_sql}\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t (sdatetime IS NULL AND edatetime IS NULL)\n\t\t\t\t\t\t\t\t\t\t\t\t\t OR \n\t\t\t\t\t\t\t\t\t\t\t\t\t (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsdatetime <= " . time() . " AND edatetime >= " . time() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t)";
$va_sql_wheres[] = "({$vs_sql})";
}
}
$qr_res = $o_db->query("SELECT cs.set_id, cs.user_id, type_id, cu.fname, cu.lname\n\t\t\t\t\t\t\t\t\tFROM ca_sets cs\n\t\t\t\t\t\t\t\t\tINNER JOIN ca_users AS cu ON cs.user_id = cu.user_id\n\t\t\t\t\t\t\t\t\t" . join("\n", $va_extra_joins) . "\n\t\t\t\t\t\t\t\t\t" . (sizeof($va_sql_wheres) ? "WHERE " : "") . " " . join(" AND ", $va_sql_wheres) . "\n\t\t\t\t\t\t\t\t\t", $va_sql_params);
$va_sets = array();
$t_list = new ca_lists();
while ($qr_res->nextRow()) {
$vn_table_num = $qr_res->get('table_num');
if (!isset($va_type_name_cache[$vn_table_num]) || !($vs_set_type = $va_type_name_cache[$vn_table_num])) {
$vs_set_type = $va_type_name_cache[$vn_table_num] = $this->getSetContentTypeName($vn_table_num, array('number' => 'plural'));
}
$vs_type = $t_list->getItemFromListForDisplayByItemID('set_types', $qr_res->get('type_id'));
$va_sets[$qr_res->get('set_id')] = array_merge($qr_res->getRow(), array('set_content_type' => $vs_set_type, 'set_type' => $vs_type));
}
return $va_sets;
} else {
return false;
}
}
示例15: haveAccessToSet
/**
* Determines if user has access to a set at a specified access level.
*
* @param int $pn_user_id user_id of user to check set access for
* @param int $pn_access type of access required. Use __CA_SET_READ_ACCESS__ for read-only access or __CA_SET_EDIT_ACCESS__ for editing (full) access
* @param int $pn_set_id The id of the set to check. If omitted then currently loaded set will be checked.
* @param array $pa_options No options yet
* @return bool True if user has access, false if not
*/
public function haveAccessToSet($pn_user_id, $pn_access, $pn_set_id = null, $pa_options = null)
{
if ($this->getAppConfig()->get('dont_enforce_access_control_for_ca_sets')) {
return true;
}
if ($pn_set_id) {
$vn_set_id = $pn_set_id;
$t_set = new ca_sets($vn_set_id);
$vn_set_user_id = $t_set->get('user_id');
} else {
$t_set = $this;
$vn_set_user_id = $t_set->get('user_id');
}
if (!$vn_set_id && !($vn_set_id = $t_set->getPrimaryKey())) {
return true;
// new set
}
if ($t_set->get('deleted') != 0) {
return false;
}
// set is deleted
if (isset(ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access])) {
return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access];
}
if ($vn_set_user_id == $pn_user_id) {
// owners have all access
return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = true;
}
if ($t_set->get('access') > 0 && $pn_access == __CA_SET_READ_ACCESS__) {
// public sets are readable by all
return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = true;
}
//
// If user is admin or has set admin privs allow them access to the set
//
$t_user = new ca_users();
if ($t_user->load($pn_user_id) && ($t_user->canDoAction('is_administrator') || $t_user->canDoAction('can_administrate_sets'))) {
return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = true;
}
$o_db = $this->getDb();
$qr_res = $o_db->query($vs_sql = "\n\t\t\tSELECT sxg.set_id \n\t\t\tFROM ca_sets_x_user_groups sxg \n\t\t\tINNER JOIN ca_user_groups AS ug ON sxg.group_id = ug.group_id\n\t\t\tINNER JOIN ca_users_x_groups AS uxg ON uxg.group_id = ug.group_id\n\t\t\tWHERE \n\t\t\t\t(sxg.access >= ?) AND (uxg.user_id = ?) AND (sxg.set_id = ?)\n\t\t\t\tAND\n\t\t\t\t(\n\t\t\t\t\t(sxg.sdatetime <= " . time() . " AND sxg.edatetime >= " . time() . ")\n\t\t\t\t\tOR\n\t\t\t\t\t(sxg.sdatetime IS NULL and sxg.edatetime IS NULL)\n\t\t\t\t)\n\t\t", (int) $pn_access, (int) $pn_user_id, (int) $vn_set_id);
if ($qr_res->numRows() > 0) {
return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = true;
}
$qr_res = $o_db->query("\n\t\t\tSELECT sxu.set_id \n\t\t\tFROM ca_sets_x_users sxu\n\t\t\tINNER JOIN ca_users AS u ON sxu.user_id = u.user_id\n\t\t\tWHERE \n\t\t\t\t(sxu.access >= ?) AND (u.user_id = ?) AND (sxu.set_id = ?)\n\t\t\t\tAND\n\t\t\t\t(\n\t\t\t\t\t(sxu.sdatetime <= " . time() . " AND sxu.edatetime >= " . time() . ")\n\t\t\t\t\tOR\n\t\t\t\t\tsxu.sdatetime IS NULL and sxu.edatetime IS NULL\n\t\t\t\t)\n\t\t", (int) $pn_access, (int) $pn_user_id, (int) $vn_set_id);
if ($qr_res->numRows() > 0) {
return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = true;
}
return ca_sets::$s_have_access_to_set_cache[$vn_set_id . '/' . $pn_user_id . '/' . $pn_access] = false;
}