Exemplo n.º 1
0
function credit_hook_rate_addusercredit($uid, $amount)
{
    global $plugin_config;
    $db_table = $plugin_config['credit']['db_table'];
    $parent_uid = user_getparentbyuid($uid);
    $username = user_uid2username($uid);
    $status = user_getfieldbyuid($uid, 'status');
    $balance = (double) rate_getusercredit($username);
    $amount = (double) $amount;
    if (abs($amount) <= 0) {
        _log('amount cannot be zero. amount:[' . $amount . ']', 2, 'credit_hook_rate_addusercredit');
        return FALSE;
    }
    // add to balance
    $balance = $balance + $amount;
    // record it
    $id = dba_add($db_table, array('parent_uid' => $parent_uid, 'uid' => $uid, 'username' => $username, 'status' => $status, 'create_datetime' => core_get_datetime(), 'amount' => $amount, 'balance' => $balance, 'flag_deleted' => 0));
    // update user's credit
    if ($id) {
        _log('saved id:' . $id . ' parent_uid:' . $parent_uid . ' uid:' . $uid . ' username:'******' amount:' . $amount . ' balance:' . $balance, 3, 'credit_add');
        if (rate_setusercredit($uid, $balance)) {
            _log('updated uid:' . $uid . ' credit:' . $balance, 3, 'credit_add');
            return TRUE;
        } else {
            _log('fail to update uid:' . $uid . ' credit:' . $balance, 3, 'credit_add');
            dba_remove($db_table, array('id' => $id));
            return FALSE;
        }
    } else {
        _log('fail to save parent_uid:' . $parent_uid . ' uid:' . $uid . ' username:'******' amount:' . $amount . ' balance:' . $balance, 3, 'credit_add');
        return FALSE;
    }
}
Exemplo n.º 2
0
function phonebook_hook_phonebook_search_group($uid, $keyword = "", $count = 0)
{
    $ret = array();
    $db_query = "\n\t\tSELECT DISTINCT id AS gpid, name AS group_name, code, flag_sender\n\t\tFROM " . _DB_PREF_ . "_featurePhonebook_group\n\t\tWHERE (\n\t\t\tuid='{$uid}' OR\n\t\t\tid in (\n\t\t\t\tSELECT B.id AS id FROM " . _DB_PREF_ . "_featurePhonebook AS A\n\t\t\t\tLEFT JOIN " . _DB_PREF_ . "_featurePhonebook_group_contacts AS C ON A.id=C.pid\n\t\t\t\tLEFT JOIN " . _DB_PREF_ . "_featurePhonebook_group AS B ON B.id=C.gpid\n\t\t\t\tWHERE A.mobile='" . user_getfieldbyuid($uid, 'mobile') . "' AND B.flag_sender='1'\n\t\t\t) OR (\n\t\t\tuid <>'{$uid}' AND flag_sender>'1'\n\t\t\t)\n\t\t)";
    if ($keyword) {
        $db_query .= " AND (\n\t\t\t\t\tname LIKE '%" . $keyword . "%' OR\n\t\t\t\t\tcode LIKE '%" . $keyword . "%'\n\t\t\t\t\t)";
    }
    if ($count > 0) {
        $db_query .= " LIMIT " . $count;
    }
    $db_result = dba_query($db_query);
    while ($db_row = dba_fetch_array($db_result)) {
        $ret[] = $db_row;
    }
    return $ret;
}
Exemplo n.º 3
0
     break;
 case "sender_id_edit":
     $nav = themes_nav_session();
     $search = themes_search_session();
     if ($nav['url']) {
         $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
     } else {
         $ref = 'index.php?app=main&inc=core_sender_id&op=sender_id_list';
     }
     $items['id'] = $_REQUEST['id'];
     $items['uid'] = $uid;
     $items['sender_id'] = $data_sender_id[0]['registry_key'];
     $items['description'] = sender_id_description($uid, $data_sender_id[0]['registry_key']);
     if (auth_isadmin()) {
         $select_approve = _yesno('approved', $data_sender_id[0]['registry_value']);
         $select_users = user_getfieldbyuid($uid, 'name') . ' (' . user_uid2username($uid) . ')';
     }
     $default_sender_id = sender_id_default_get($uid);
     $select_default = _yesno('default', strtoupper($data_sender_id[0]['registry_key']) == strtoupper($default_sender_id) ? 1 : 0);
     $tpl = array('name' => 'sender_id_add', 'vars' => array('DIALOG_DISPLAY' => _dialog(), 'FORM_TITLE' => _('Manage sender ID'), 'FORM_SUBTITLE' => _('Edit sender ID'), 'ACTION_URL' => _u('index.php?app=main&inc=core_sender_id&op=sender_id_edit_yes'), 'BUTTON_BACK' => _back($ref), 'HTTP_PATH_THEMES' => _HTTP_PATH_THEMES_, 'HINT_DEFAULT' => _hint(_('Only when the sender ID is approved')), 'input_tag' => 'readonly', 'Sender ID' => _mandatory(_('Sender ID')), 'Description' => _('Description'), 'User' => _('User'), 'Approve sender ID' => _('Approve sender ID'), 'Set as default' => _('Set as default')), 'ifs' => array('isadmin' => auth_isadmin()), 'injects' => array('select_default', 'select_approve', 'select_users', 'items', 'icon_config', 'core_config'));
     _p(tpl_apply($tpl));
     break;
 case "sender_id_edit_yes":
     if (sender_id_update($uid, $c_sender_id, $c_sender_id_description, $_REQUEST['default'], $_REQUEST['approved'])) {
         $_SESSION['dialog']['info'][] = _('Sender ID description has been updated') . ' (' . _('Sender ID') . ': ' . $c_sender_id . ')';
     } else {
         $_SESSION['dialog']['info'][] = _('Fail to update due to invalid sender ID') . ' (' . _('Sender ID') . ': ' . $c_sender_id . ')';
     }
     header("Location: " . _u('index.php?app=main&inc=core_sender_id&op=sender_id_edit&id=' . $_REQUEST['id']));
     exit;
     break;
Exemplo n.º 4
0
/**
 * Check if visitor has certain ACL
 *
 * @param string $acl
 *        Access Control List
 * @return boolean TRUE if valid and visitor has certain ACL
 */
function auth_isacl($acl)
{
    if (auth_isvalid()) {
        if (auth_isadmin()) {
            return TRUE;
        } else {
            $user_acl_id = user_getfieldbyuid($_SESSION['uid'], 'acl_id');
            $user_acl_name = acl_getname($user_acl_id);
            if ($acl && $user_acl_name && strtoupper($acl) == strtoupper($user_acl_name)) {
                return TRUE;
            }
        }
    }
    return FALSE;
}
Exemplo n.º 5
0
             } else {
                 // ban
                 $action .= "<a href=\"javascript: ConfirmURL('" . addslashes(_("Are you sure you want to ban account")) . " " . $list[$i]['username'] . " ?','" . _u('index.php?app=main&inc=core_user&route=user_mgmnt&op=user_ban&uname=' . $list[$i]['username']) . "&view=" . $view . "')\">" . $icon_config['ban'] . "</a>";
                 $banned_icon = '';
             }
         }
         // remove user except those who still have subusers
         $subusers = user_getsubuserbyuid($list[$i]['uid']);
         if (count($subusers) > 0) {
             $action .= _hint(_('Please remove all subusers from this user to delete'));
         } else {
             $action .= "<a href=\"javascript: ConfirmURL('" . addslashes(_("Are you sure you want to delete user")) . " " . $list[$i]['username'] . " ?','" . _u('index.php?app=main&inc=core_user&route=user_mgmnt&op=user_del&uname=' . $list[$i]['username']) . "&view=" . $view . "')\">" . $icon_config['user_delete'] . "</a>";
         }
         // subuser shows parent column
         if ($list[$i]['status'] == 4) {
             $isadmin = user_getfieldbyuid($list[$i]['parent_uid'], 'status') == 2 ? $icon_config['admin'] : '';
             $parent_column_row = "<td>" . user_uid2username($list[$i]['parent_uid']) . " " . $isadmin . "</td>";
         }
         $j--;
         $content .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td>" . core_display_datetime($list[$i]['register_datetime']) . "</td>\n\t\t\t\t\t" . $parent_column_row . "\n\t\t\t\t\t<td>" . $banned_icon . "" . $list[$i]['username'] . " </td>\n\t\t\t\t\t<td>" . $list[$i]['name'] . "</td>\n\t\t\t\t\t<td>" . $list[$i]['mobile'] . "</td>\n\t\t\t\t\t<td>" . rate_getusercredit($list[$i]['username']) . "</td>\n\t\t\t\t\t<td>" . acl_getnamebyuid($list[$i]['uid']) . "</td>\n\t\t\t\t\t<td>" . $action . "</td>\n\t\t\t\t</tr>";
     }
     $content .= "\n\t\t\t</tbody></table>\n\t\t\t</div>\n\t\t\t<div class=pull-right>" . $nav['form'] . "</div>";
     _p($content);
     break;
 case "user_add":
     if ($err = TRUE) {
         $content = _dialog();
     }
     $add_datetime_timezone = $_REQUEST['add_datetime_timezone'];
     $add_datetime_timezone = $add_datetime_timezone ? $add_datetime_timezone : core_get_timezone();
     // get language options
Exemplo n.º 6
0
function webservices_account_pref($uid, $data = array())
{
    if (!$data['name']) {
        $data['name'] = user_getfieldbyuid($uid, 'name');
    }
    if (!$data['email']) {
        $data['email'] = user_getfieldbyuid($uid, 'email');
    }
    $ret = user_edit($uid, $data);
    if ($ret['status']) {
        $json['status'] = 'OK';
        $json['error'] = '0';
        $json['info'] = $ret['error_string'];
    } else {
        $json['status'] = 'ERR';
        $json['error'] = '616';
        $json['info'] = $ret['error_string'];
    }
    return $json;
}
Exemplo n.º 7
0
/**
 * Get list of subusers under a user by uid
 *
 * @param integer $uid
 *        User ID
 * @return array Array of subusers
 */
function user_getsubuserbyuid($uid)
{
    $uid = (int) $uid;
    if ($uid) {
        $parent_status = user_getfieldbyuid($uid, 'status');
        if ($parent_status == 2 || $parent_status == 3) {
            $conditions = array('flag_deleted' => 0, 'parent_uid' => $uid, 'status' => 4);
            return dba_search(_DB_PREF_ . '_tblUser', '*', $conditions);
        }
    }
    return array();
}