Example #1
0
        }
        header("Location: " . _u('index.php?app=main&inc=core_sender_id&op=sender_id_edit&id=' . $_REQUEST['id']));
        exit;
        break;
    case "toggle_status":
        $search = array('id' => $_REQUEST['id'], 'registry_family' => 'sender_id');
        foreach (registry_search_record($search) as $row) {
            $status = $row['registry_value'] == 0 ? 1 : 0;
            $items[$row['registry_key']] = $status;
            registry_update($row['uid'], 'features', 'sender_id', $items);
        }
        $_SESSION['dialog']['info'][] = ($status == 1 ? _('Sender ID is now approved') : _('Sender ID is now disabled')) . ' (' . _('Sender ID') . ': ' . $row['registry_key'] . ')';
        header("Location: " . _u('index.php?app=main&inc=core_sender_id&op=sender_id_list'));
        exit;
        break;
    case "sender_id_delete":
        $nav = themes_nav_session();
        $search = themes_search_session();
        $ref = $nav['url'] . '&search_keyword=' . $search['keyword'] . '&page=' . $nav['page'] . '&nav=' . $nav['nav'];
        $uid = auth_isadmin() && $data_sender_id[0]['uid'] ? $data_sender_id[0]['uid'] : $user_config['uid'];
        registry_remove($uid, 'features', 'sender_id', $data_sender_id[0]['registry_key']);
        registry_remove($uid, 'features', 'sender_id_description', $data_sender_id[0]['registry_key']);
        $default_sender_id = sender_id_default_get($uid);
        if (strtoupper($data_sender_id[0]['registry_key']) == strtoupper($default_sender_id)) {
            sender_id_default_set($data_sender_id[0]['uid'], '');
        }
        $_SESSION['dialog']['info'][] = _('Sender ID has been removed') . ' (' . _('Sender ID') . ': ' . $data_sender_id[0]['registry_key'] . ')';
        header("Location: " . _u($ref));
        exit;
        break;
}
Example #2
0
/**
 * Update sender ID
 *
 * @param integer $uid
 *        User ID
 * @param string $sender_id
 *        Sender ID
 * @param string $sender_id_description
 *        Sender ID description
 * @param integer $isdefault
 *        Flag 1 for default sender ID
 * @param integer $isapproved
 *        Flag 1 for approved sender ID
 * @return boolean TRUE when new sender ID has been updated
 */
function sender_id_update($uid, $sender_id, $sender_id_description = '', $isdefault = '_', $isapproved = '_')
{
    global $user_config;
    if (sender_id_check($uid, $sender_id)) {
        $default = '_';
        if ($isdefault !== '_') {
            $default = (int) $isdefault ? 1 : 0;
        }
        if ($isapproved !== '_') {
            if (auth_isadmin()) {
                $approved = (int) $isapproved ? 1 : 0;
                $data_sender_id = array($sender_id => $approved);
            }
        }
        $sender_id_description = trim($sender_id_description) ? trim($sender_id_description) : $sender_id;
        $data_description = array($sender_id => $sender_id_description);
        $uid = auth_isadmin() && $uid ? $uid : $user_config['uid'];
        if ($uid) {
            if ($data_sender_id) {
                registry_update($uid, 'features', 'sender_id', $data_sender_id);
            }
            registry_update($uid, 'features', 'sender_id_desc', $data_description);
        } else {
            // unknown error
            return FALSE;
        }
        // set default
        if ($default !== '_') {
            if (auth_isadmin() && $default && $approved) {
                // set default if isadmin, default and approved
                sender_id_default_set($uid, $sender_id);
            } else {
                // set to empty (remove default)
                sender_id_default_set($uid, '');
            }
        }
        return TRUE;
    } else {
        // not found
        return FALSE;
    }
}